27 #include <Classes.hpp>
28 #include <Controls.hpp>
29 #include <StdCtrls.hpp>
31 #include <Buttons.hpp>
32 #include <ExtCtrls.hpp>
34 #include <Dialogs.hpp>
35 #include <Graphics.hpp>
36 #include <ComCtrls.hpp>
37 #include <Clipbrd.hpp>
61 #include <Filectrl.hpp>
64 #include <Vcl.HTMLHelpViewer.hpp>
65 #pragma package(smart_init)
66 #pragma link "Vcl.HTMLHelpViewer" //added at v2.0.0 for access to the .chm help file
67 #pragma resource "*.dfm"
89 Screen->Cursor = TCursor(-11);
95 ProgramVersion = GetVersion();
102 CurDir = AnsiString(GetCurrentDir());
104 UnicodeString FullProgramName = GetModuleName(0);
106 UnicodeString ProgramName = ExtractFileName(FullProgramName);
108 UnicodeString ProgramDirectoryName = ExtractFilePath(FullProgramName);
111 if(!FileExists(ProgramName))
113 if(!SetCurrentDir(ProgramDirectoryName))
115 ShowMessage(
"The working directory does not contain the railway executable file so the program cannot "
116 "open. This is usually because the program has been selected via the right-click taskbar icon though it may "
117 "also happen in other circumstances. It is caused by the Windows operating system re-assigning the "
118 "working directory for some unknown reason, though whether or not it happens appears to depend on the "
119 "Windows update version.\n\n"
120 "To avoid this happening please open the program by double clicking the program icon on the desktop "
121 "if there is one, or the program icon shown in Windows Explorer.");
122 Application->Terminate();
126 CurDir = AnsiString(GetCurrentDir());
130 if(!DirectoryExists(RAILWAY_DIR_NAME))
132 if(!CreateDir(RAILWAY_DIR_NAME))
138 if(!DirectoryExists(TIMETABLE_DIR_NAME))
140 if(!CreateDir(TIMETABLE_DIR_NAME))
145 if(!DirectoryExists(PERFLOG_DIR_NAME))
147 if(!CreateDir(PERFLOG_DIR_NAME))
152 if(!DirectoryExists(SESSION_DIR_NAME))
154 if(!CreateDir(SESSION_DIR_NAME))
159 if(!DirectoryExists(IMAGE_DIR_NAME))
161 if(!CreateDir(IMAGE_DIR_NAME))
166 if(!DirectoryExists(FORMATTEDTT_DIR_NAME))
168 if(!CreateDir(FORMATTEDTT_DIR_NAME))
173 if(!DirectoryExists(USERGRAPHICS_DIR_NAME))
175 if(!CreateDir(USERGRAPHICS_DIR_NAME))
182 ShowMessage(
"Failed to create one or more of folders: " + RAILWAY_DIR_NAME +
", " + TIMETABLE_DIR_NAME +
", " + PERFLOG_DIR_NAME +
", " +
183 SESSION_DIR_NAME +
", " + IMAGE_DIR_NAME +
", " + FORMATTEDTT_DIR_NAME +
", " + USERGRAPHICS_DIR_NAME +
", " +
184 "program operation will be restricted");
186 Application->HelpFile = AnsiString(CurDir +
"\\Help.chm");
188 MainMenu1->AutoHotkeys = maManual;
189 PopupMenu->AutoHotkeys = maManual;
194 int DispW = (Screen->Width - 64) / 16;
195 int DispH = (Screen->Height - 192) / 16;
196 MainScreen->Width = DispW * 16;
197 MainScreen->Height = DispH * 16;
199 Display =
new TDisplay(MainScreen, PerformanceLogBox, OutputLog1, OutputLog2, OutputLog3, OutputLog4, OutputLog5, OutputLog6, OutputLog7, OutputLog8,
200 OutputLog9, OutputLog10);
204 HiddenScreen->Width = MainScreen->Width;
205 HiddenScreen->Height = MainScreen->Height;
206 HiddenDisplay =
new TDisplay(HiddenScreen, PerformanceLogBox, OutputLog1, OutputLog2, OutputLog3, OutputLog4, OutputLog5, OutputLog6, OutputLog7,
207 OutputLog8, OutputLog9, OutputLog10);
216 SelectBitmap =
new Graphics::TBitmap;
217 SelectBitmap->PixelFormat = pf8bit;
218 SelectBitmap->Transparent =
true;
223 LengthWarningSentFlag =
false;
224 PasteWarningSentFlag =
false;
225 FillSelectionMessageSentFlag =
false;
226 LCManualLowerBarriersMessageSent =
false;
227 RecoverClipboardMessageSent =
false;
228 TooLongMessageSentFlag =
false;
229 TooShortMessageSentFlag =
false;
232 TrackInfoOnOffMenuItem->Caption =
"Show";
233 TrainStatusInfoOnOffMenuItem->Caption =
"Hide Status";
234 TrainTTInfoOnOffMenuItem->Caption =
"Hide Timetable";
257 RouteFlashDuration = 0.0;
258 PointsFlashDuration = 0.0;
261 TrackElementPanel->Color =
clB5G5R4;
264 LoadUserGraphicDialog->InitialDir = CurDir +
"\\" + USERGRAPHICS_DIR_NAME;
267 SigsOnLeftImage1->Picture->Bitmap->LoadFromResourceName(0,
"SigsOnLeft");
268 SigsOnLeftImage2->Picture->Bitmap->LoadFromResourceName(0,
"SigsOnLeft");
269 SigsOnLeftImage1->Transparent =
true;
270 SigsOnLeftImage2->Transparent =
true;
271 SigsOnLeftImage1->Picture->Bitmap->TransparentColor =
clB5G5R5;
272 SigsOnLeftImage2->Picture->Bitmap->TransparentColor =
clB5G5R5;
273 SigsOnRightImage1->Picture->Bitmap->LoadFromResourceName(0,
"SigsOnRight");
274 SigsOnRightImage2->Picture->Bitmap->LoadFromResourceName(0,
"SigsOnRight");
275 SigsOnRightImage1->Transparent =
true;
276 SigsOnRightImage2->Transparent =
true;
277 SigsOnRightImage1->Picture->Bitmap->TransparentColor =
clB5G5R5;
278 SigsOnRightImage2->Picture->Bitmap->TransparentColor =
clB5G5R5;
280 SaveRailwayDialog->InitialDir = CurDir +
"\\" + RAILWAY_DIR_NAME;
281 LoadRailwayDialog->InitialDir = CurDir +
"\\" + RAILWAY_DIR_NAME;
282 TimetableDialog->InitialDir = CurDir +
"\\" + TIMETABLE_DIR_NAME;
283 SaveTTDialog->InitialDir = CurDir +
"\\" + TIMETABLE_DIR_NAME;
284 LoadSessionDialog->InitialDir = CurDir +
"\\" + SESSION_DIR_NAME;
286 std::ifstream ConfigFile((CurDir +
"\\Config.txt").c_str());
287 if(ConfigFile.fail())
289 ConverttoRightHandSignalsMenuItem->Caption =
"Convert to Right Hand Signals";
290 SigImagePanel->Caption =
"Signals will be on the left hand side of the track";
291 SigsOnLeftImage1->Visible =
true;
292 SigsOnLeftImage2->Visible =
true;
293 SigsOnRightImage1->Visible =
false;
294 SigsOnRightImage2->Visible =
false;
296 "This program is free software released under the terms of the GNU General Public License Version 3, as published by the Free Software Foundation. " "It may be used or redistributed in accordance with that license and is released in the hope that it will be useful, but WITHOUT ANY WARRANTY; "
297 "without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details - " "you should have received a copy along with this program but if not see <http://www.gnu.org/licenses/>."
302 AnsiString ConfigStr =
"";
310 AnsiString ConfigValue = ConfigStr.SubString(9, ConfigStr.Length() - 8);
311 if(ConfigStr.SubString(1, 8) ==
"Signals=")
313 if(ConfigValue ==
"right")
316 ConverttoRightHandSignalsMenuItem->Caption =
"Convert to Left Hand Signals";
319 LoadGroundSignalGlyphs(1);
323 LoadNormalSignalGlyphs(1);
325 SigImagePanel->Caption =
"Signals will be on the right hand side of the track";
326 SigsOnLeftImage1->Visible =
false;
327 SigsOnLeftImage2->Visible =
false;
328 SigsOnRightImage1->Visible =
true;
329 SigsOnRightImage2->Visible =
true;
333 ConverttoRightHandSignalsMenuItem->Caption =
"Convert to Right Hand Signals";
334 SigImagePanel->Caption =
"Signals will be on the left hand side of the track";
335 SigsOnLeftImage1->Visible =
true;
336 SigsOnLeftImage2->Visible =
true;
337 SigsOnRightImage1->Visible =
false;
338 SigsOnRightImage2->Visible =
false;
341 if(ConfigStr.SubString(1, 8) ==
"BgndCol=")
345 if(ConfigValue ==
"white")
349 else if(ConfigValue ==
"blue")
354 if(ConfigStr.SubString(1, 8) ==
"RLYLocn=")
356 if(DirectoryExists(ConfigValue))
358 SaveRailwayDialog->InitialDir = ConfigStr.SubString(9, ConfigStr.Length() - 8);
359 LoadRailwayDialog->InitialDir = ConfigStr.SubString(9, ConfigStr.Length() - 8);
362 else if(ConfigStr.SubString(1, 8) ==
"TTBLocn=")
364 if(DirectoryExists(ConfigValue))
366 TimetableDialog->InitialDir = ConfigStr.SubString(9, ConfigStr.Length() - 8);
367 SaveTTDialog->InitialDir = ConfigStr.SubString(9, ConfigStr.Length() - 8);
370 else if(ConfigStr.SubString(1, 8) ==
"SSNLocn=")
372 if(DirectoryExists(ConfigValue))
374 LoadSessionDialog->InitialDir = ConfigStr.SubString(9, ConfigStr.Length() - 8);
378 while(!ConfigFile.eof());
381 SpeedButton1->Glyph->LoadFromResourceName(0,
"gl1");
382 SpeedButton2->Glyph->LoadFromResourceName(0,
"gl2");
383 SpeedButton3->Glyph->LoadFromResourceName(0,
"gl3");
384 SpeedButton4->Glyph->LoadFromResourceName(0,
"gl4");
385 SpeedButton5->Glyph->LoadFromResourceName(0,
"gl5");
386 SpeedButton6->Glyph->LoadFromResourceName(0,
"gl6");
387 SpeedButton7->Glyph->LoadFromResourceName(0,
"gl7");
388 SpeedButton8->Glyph->LoadFromResourceName(0,
"gl8");
389 SpeedButton9->Glyph->LoadFromResourceName(0,
"gl9");
390 SpeedButton10->Glyph->LoadFromResourceName(0,
"gl10");
391 SpeedButton11->Glyph->LoadFromResourceName(0,
"gl11");
392 SpeedButton12->Glyph->LoadFromResourceName(0,
"gl12");
393 SpeedButton13->Glyph->LoadFromResourceName(0,
"gl13");
394 SpeedButton14->Glyph->LoadFromResourceName(0,
"gl14");
395 SpeedButton15->Glyph->LoadFromResourceName(0,
"gl15");
396 SpeedButton16->Glyph->LoadFromResourceName(0,
"gl16");
397 SpeedButton18->Glyph->LoadFromResourceName(0,
"gl18");
398 SpeedButton19->Glyph->LoadFromResourceName(0,
"gl19");
399 SpeedButton20->Glyph->LoadFromResourceName(0,
"gl20");
400 SpeedButton21->Glyph->LoadFromResourceName(0,
"gl21");
401 SpeedButton22->Glyph->LoadFromResourceName(0,
"gl22");
402 SpeedButton23->Glyph->LoadFromResourceName(0,
"gl23");
403 SpeedButton24->Glyph->LoadFromResourceName(0,
"gl24");
404 SpeedButton25->Glyph->LoadFromResourceName(0,
"gl25");
405 SpeedButton26->Glyph->LoadFromResourceName(0,
"gl26");
406 SpeedButton27->Glyph->LoadFromResourceName(0,
"gl27");
407 SpeedButton28->Glyph->LoadFromResourceName(0,
"gl28");
408 SpeedButton29->Glyph->LoadFromResourceName(0,
"gl29");
409 SpeedButton30->Glyph->LoadFromResourceName(0,
"gl30");
410 SpeedButton31->Glyph->LoadFromResourceName(0,
"gl31");
411 SpeedButton32->Glyph->LoadFromResourceName(0,
"gl32");
412 SpeedButton33->Glyph->LoadFromResourceName(0,
"gl33");
413 SpeedButton34->Glyph->LoadFromResourceName(0,
"gl34");
414 SpeedButton35->Glyph->LoadFromResourceName(0,
"gl35");
415 SpeedButton36->Glyph->LoadFromResourceName(0,
"gl36");
416 SpeedButton37->Glyph->LoadFromResourceName(0,
"gl37");
417 SpeedButton38->Glyph->LoadFromResourceName(0,
"gl38");
418 SpeedButton39->Glyph->LoadFromResourceName(0,
"gl39");
419 SpeedButton40->Glyph->LoadFromResourceName(0,
"gl40");
420 SpeedButton41->Glyph->LoadFromResourceName(0,
"gl41");
421 SpeedButton42->Glyph->LoadFromResourceName(0,
"gl42");
422 SpeedButton43->Glyph->LoadFromResourceName(0,
"gl43");
423 SpeedButton44->Glyph->LoadFromResourceName(0,
"gl44");
424 SpeedButton45->Glyph->LoadFromResourceName(0,
"gl45");
425 SpeedButton46->Glyph->LoadFromResourceName(0,
"gl46");
426 SpeedButton47->Glyph->LoadFromResourceName(0,
"gl47");
427 SpeedButton48->Glyph->LoadFromResourceName(0,
"gl48");
428 SpeedButton49->Glyph->LoadFromResourceName(0,
"gl49");
429 SpeedButton50->Glyph->LoadFromResourceName(0,
"gl50");
430 SpeedButton51->Glyph->LoadFromResourceName(0,
"gl51");
431 SpeedButton52->Glyph->LoadFromResourceName(0,
"gl52");
432 SpeedButton53->Glyph->LoadFromResourceName(0,
"gl53");
433 SpeedButton54->Glyph->LoadFromResourceName(0,
"gl54");
434 SpeedButton55->Glyph->LoadFromResourceName(0,
"gl55");
435 SpeedButton56->Glyph->LoadFromResourceName(0,
"gl56");
436 SpeedButton57->Glyph->LoadFromResourceName(0,
"gl57");
437 SpeedButton58->Glyph->LoadFromResourceName(0,
"gl58");
438 SpeedButton59->Glyph->LoadFromResourceName(0,
"gl59");
439 SpeedButton60->Glyph->LoadFromResourceName(0,
"gl60");
440 SpeedButton61->Glyph->LoadFromResourceName(0,
"gl61");
441 SpeedButton62->Glyph->LoadFromResourceName(0,
"gl62");
442 SpeedButton63->Glyph->LoadFromResourceName(0,
"gl63");
443 SpeedButton64->Glyph->LoadFromResourceName(0,
"gl64");
444 SpeedButton65->Glyph->LoadFromResourceName(0,
"gl65");
445 SpeedButton66->Glyph->LoadFromResourceName(0,
"gl66");
446 SpeedButton67->Glyph->LoadFromResourceName(0,
"gl67");
447 SpeedButton68->Glyph->LoadFromResourceName(0,
"gl68");
448 SpeedButton69->Glyph->LoadFromResourceName(0,
"gl69");
449 SpeedButton70->Glyph->LoadFromResourceName(0,
"gl70");
450 SpeedButton71->Glyph->LoadFromResourceName(0,
"gl71");
451 SpeedButton72->Glyph->LoadFromResourceName(0,
"gl72");
452 SpeedButton73->Glyph->LoadFromResourceName(0,
"gl73");
453 SpeedButton74->Glyph->LoadFromResourceName(0,
"gl74");
454 SpeedButton75->Glyph->LoadFromResourceName(0,
"gl75");
455 SpeedButton76->Glyph->LoadFromResourceName(0,
"gl76");
456 SpeedButton77->Glyph->LoadFromResourceName(0,
"gl77");
457 SpeedButton78->Glyph->LoadFromResourceName(0,
"gl78");
458 SpeedButton79->Glyph->LoadFromResourceName(0,
"gl79");
459 SpeedButton80->Glyph->LoadFromResourceName(0,
"gl80");
460 SpeedButton81->Glyph->LoadFromResourceName(0,
"gl81");
461 SpeedButton82->Glyph->LoadFromResourceName(0,
"gl82");
462 SpeedButton83->Glyph->LoadFromResourceName(0,
"gl83");
463 SpeedButton84->Glyph->LoadFromResourceName(0,
"gl84");
464 SpeedButton85->Glyph->LoadFromResourceName(0,
"gl85");
465 SpeedButton86->Glyph->LoadFromResourceName(0,
"gl86");
466 SpeedButton87->Glyph->LoadFromResourceName(0,
"gl87");
467 SpeedButton88->Glyph->LoadFromResourceName(0,
"gl88set");
468 SpeedButton89->Glyph->LoadFromResourceName(0,
"gl89set");
469 SpeedButton90->Glyph->LoadFromResourceName(0,
"gl90set");
470 SpeedButton91->Glyph->LoadFromResourceName(0,
"gl91set");
471 SpeedButton92->Glyph->LoadFromResourceName(0,
"gl92set");
472 SpeedButton93->Glyph->LoadFromResourceName(0,
"gl93set");
473 SpeedButton94->Glyph->LoadFromResourceName(0,
"gl94set");
474 SpeedButton95->Glyph->LoadFromResourceName(0,
"gl95set");
475 SpeedButton96->Glyph->LoadFromResourceName(0,
"ConcourseGlyph");
476 SpeedButton97->Glyph->LoadFromResourceName(0,
"gl97");
477 SpeedButton98->Glyph->LoadFromResourceName(0,
"gl98");
478 SpeedButton99->Glyph->LoadFromResourceName(0,
"gl99");
479 SpeedButton100->Glyph->LoadFromResourceName(0,
"gl100");
480 SpeedButton101->Glyph->LoadFromResourceName(0,
"gl101");
481 SpeedButton102->Glyph->LoadFromResourceName(0,
"gl102");
482 SpeedButton103->Glyph->LoadFromResourceName(0,
"gl103");
483 SpeedButton104->Glyph->LoadFromResourceName(0,
"gl104");
484 SpeedButton105->Glyph->LoadFromResourceName(0,
"gl105");
485 SpeedButton106->Glyph->LoadFromResourceName(0,
"gl106");
486 SpeedButton107->Glyph->LoadFromResourceName(0,
"gl107");
487 SpeedButton108->Glyph->LoadFromResourceName(0,
"gl108");
488 SpeedButton109->Glyph->LoadFromResourceName(0,
"gl109");
489 SpeedButton110->Glyph->LoadFromResourceName(0,
"gl110");
490 SpeedButton111->Glyph->LoadFromResourceName(0,
"gl111");
491 SpeedButton112->Glyph->LoadFromResourceName(0,
"gl112");
492 SpeedButton113->Glyph->LoadFromResourceName(0,
"gl113");
493 SpeedButton114->Glyph->LoadFromResourceName(0,
"gl114");
494 SpeedButton115->Glyph->LoadFromResourceName(0,
"gl115");
495 SpeedButton116->Glyph->LoadFromResourceName(0,
"gl116");
496 SpeedButton117->Glyph->LoadFromResourceName(0,
"gl117");
497 SpeedButton118->Glyph->LoadFromResourceName(0,
"gl118");
498 SpeedButton119->Glyph->LoadFromResourceName(0,
"gl119");
499 SpeedButton120->Glyph->LoadFromResourceName(0,
"gl120");
500 SpeedButton121->Glyph->LoadFromResourceName(0,
"gl121");
501 SpeedButton122->Glyph->LoadFromResourceName(0,
"gl122");
502 SpeedButton123->Glyph->LoadFromResourceName(0,
"gl123");
503 SpeedButton124->Glyph->LoadFromResourceName(0,
"gl124");
504 SpeedButton125->Glyph->LoadFromResourceName(0,
"gl125");
505 SpeedButton126->Glyph->LoadFromResourceName(0,
"gl126");
506 SpeedButton127->Glyph->LoadFromResourceName(0,
"gl127");
507 SpeedButton128->Glyph->LoadFromResourceName(0,
"gl128");
508 SpeedButton129->Glyph->LoadFromResourceName(0,
"gl129");
509 SpeedButton130->Glyph->LoadFromResourceName(0,
"gl130");
510 SpeedButton131->Glyph->LoadFromResourceName(0,
"gl131");
511 SpeedButton132->Glyph->LoadFromResourceName(0,
"gl132");
512 SpeedButton133->Glyph->LoadFromResourceName(0,
"gl133");
513 SpeedButton134->Glyph->LoadFromResourceName(0,
"gl134");
514 SpeedButton135->Glyph->LoadFromResourceName(0,
"gl135");
515 SpeedButton136->Glyph->LoadFromResourceName(0,
"gl136");
516 SpeedButton137->Glyph->LoadFromResourceName(0,
"gl137");
517 SpeedButton138->Glyph->LoadFromResourceName(0,
"gl138");
518 SpeedButton139->Glyph->LoadFromResourceName(0,
"gl139");
519 SpeedButton140->Glyph->LoadFromResourceName(0,
"gl140");
520 SpeedButton141->Glyph->LoadFromResourceName(0,
"gl141");
521 SpeedButton142->Glyph->LoadFromResourceName(0,
"gl142");
522 SpeedButton143->Glyph->LoadFromResourceName(0,
"gl143");
523 SpeedButton145->Glyph->LoadFromResourceName(0,
"gl145");
524 SpeedButton146->Glyph->LoadFromResourceName(0,
"gl146");
526 SpeedButton144->Glyph->LoadFromResourceName(0,
"LCGlyph");
528 AddPrefDirButton->Glyph->LoadFromResourceName(0,
"AddPrefDir");
529 AddTextButton->Glyph->LoadFromResourceName(0,
"AddText");
530 AddTrackButton->Glyph->LoadFromResourceName(0,
"AddTrack");
531 AutoSigsButton->Glyph->LoadFromResourceName(0,
"AutoSig");
532 CallingOnButton->Glyph->LoadFromResourceName(0,
"CallingOn");
533 DeleteAllPrefDirButton->Glyph->LoadFromResourceName(0,
"ClearAllPrefDir");
534 DeleteOnePrefDirButton->Glyph->LoadFromResourceName(0,
"ClearOnePrefDir");
535 ExitOperationButton->Glyph->LoadFromResourceName(0,
"Exit");
536 ExitPrefDirButton->Glyph->LoadFromResourceName(0,
"Exit");
537 ExitTrackButton->Glyph->LoadFromResourceName(0,
"Exit");
538 ExitTTModeButton->Glyph->LoadFromResourceName(0,
"Exit");
539 FontButton->Glyph->LoadFromResourceName(0,
"FontGraphic");
540 HomeButton->Glyph->LoadFromResourceName(0,
"Home");
541 LocationNameButton->Glyph->LoadFromResourceName(0,
"NameLocs");
542 MoveTextOrGraphicButton->Glyph->LoadFromResourceName(0,
"MoveTextOrGraphic");
543 NewHomeButton->Glyph->LoadFromResourceName(0,
"NewHome");
544 UnrestrictedButton->Glyph->LoadFromResourceName(0,
"NonSig");
545 OperateButton->Glyph->LoadFromResourceName(0,
"RunGraphic");
546 OperatorActionButton->Glyph->LoadFromResourceName(0,
"ShowOpActionPanel");
547 PerformanceLogButton->Glyph->LoadFromResourceName(0,
"ShowLog");
548 PresetAutoSigRoutesButton->Glyph->LoadFromResourceName(0,
"PresetAutoSigRoutes");
549 RouteCancelButton->Glyph->LoadFromResourceName(0,
"RouteCancel");
550 SaveRailwayPDPButton->Glyph->LoadFromResourceName(0,
"SaveRailway");
551 SaveRailwayBaseModeButton->Glyph->LoadFromResourceName(0,
"SaveRailway");
552 SaveRailwayTBPButton->Glyph->LoadFromResourceName(0,
"SaveRailway");
553 SaveSessionButton->Glyph->LoadFromResourceName(0,
"SaveSession");
554 ScreenDownButton->Glyph->LoadFromResourceName(0,
"BlackArrowDown");
555 ScreenGridButton->Glyph->LoadFromResourceName(0,
"ScreenGrid");
556 ScreenLeftButton->Glyph->LoadFromResourceName(0,
"BlackArrowLeft");
557 ScreenRightButton->Glyph->LoadFromResourceName(0,
"BlackArrowRight");
558 ScreenUpButton->Glyph->LoadFromResourceName(0,
"BlackArrowUp");
559 SetGapsButton->Glyph->LoadFromResourceName(0,
"ConnectGaps");
560 SetLengthsButton->Glyph->LoadFromResourceName(0,
"SetDists");
561 ShowHideTTButton->Glyph->LoadFromResourceName(0,
"Hide");
562 SigAspectButton->Glyph->LoadFromResourceName(0,
"FourAspect");
563 SigPrefConsecButton->Glyph->LoadFromResourceName(0,
"PrefTop");
564 SigPrefNonConsecButton->Glyph->LoadFromResourceName(0,
"PrefBottom");
565 TextOrUserGraphicGridButton->Glyph->LoadFromResourceName(0,
"PixelPrecision1");
566 TrackOKButton->Glyph->LoadFromResourceName(0,
"Validate");
567 TTClockAdjButton->Glyph->LoadFromResourceName(0,
"TTClock");
568 UserGraphicButton->Glyph->LoadFromResourceName(0,
"PictureImage");
570 BufferAttentionImage->Picture->Bitmap->LoadFromResourceName(0,
"BufferWarning");
571 CallOnImage->Picture->Bitmap->LoadFromResourceName(0,
"CallingOn");
572 CrashImage->Picture->Bitmap->LoadFromResourceName(0,
"CrashWarning");
573 DerailImage->Picture->Bitmap->LoadFromResourceName(0,
"DerailWarning");
574 SignalStopImage->Picture->Bitmap->LoadFromResourceName(0,
"SignalStopWarning");
575 SPADImage->Picture->Bitmap->LoadFromResourceName(0,
"SPADWarning");
576 TrainFailedImage->Picture->Bitmap->LoadFromResourceName(0,
"TrainFailedWarning");
577 ManualLCDownImage->Picture->Bitmap->LoadFromResourceName(0,
"ManualLCDownImage");
579 DistanceKey->Picture->Bitmap->LoadFromResourceName(0,
"DistanceKey");
580 PrefDirKey->Picture->Bitmap->LoadFromResourceName(0,
"PrefDirKey");
582 TrackLinkedImage->Picture->Bitmap->LoadFromResourceName(0,
"TrackLinkedGraphic");
583 TrackNotLinkedImage->Picture->Bitmap->LoadFromResourceName(0,
"TrackNotLinkedGraphic");
584 GapsNotSetImage->Picture->Bitmap->LoadFromResourceName(0,
"GapsNotSetGraphic");
585 GapsSetImage->Picture->Bitmap->LoadFromResourceName(0,
"GapsSetGraphic");
586 LocationNamesNotSetImage->Picture->Bitmap->LoadFromResourceName(0,
"LocNamesNotSetGraphic");
587 LocationNamesSetImage->Picture->Bitmap->LoadFromResourceName(0,
"LocNamesSetGraphic");
596 AnsiString NL =
'\n';
597 const AnsiString TTLabelStr1 =
"Start new train" + NL +
"Start new service from a split" + NL +
"Start new service from another service" + NL +
598 "Start new non-repeating shuttle finish service" + NL +
"Start new shuttle train at a timetabled stop" + NL +
599 "Start new shuttle service from a feeder";
601 const AnsiString TTLabelStr2 =
"Pass" + NL +
"Be joined by another train" + NL +
"Front split" + NL +
"Rear split" + NL +
"Change direction of train";
603 const AnsiString TTLabelStr3 =
"Finish && form a new service" + NL +
"Finish && join another train" + NL +
"Finish && exit railway" + NL +
604 "Finish && repeat shuttle, finally remain here" + NL +
"Finish && repeat shuttle, finally form a finishing service" + NL +
605 "Finish non-repeating shuttle feeder service" + NL +
"Finish && remain here";
607 const AnsiString TTLabelStr4 =
"HH:MM" + NL +
"HH:MM" + NL +
"HH:MM" + NL +
"HH:MM" + NL +
"HH:MM" + NL +
"HH:MM" + NL +
"HH:MM" + NL +
"HH:MM" + NL +
608 "HH:MM" + NL +
"HH:MM" + NL +
"HH:MM" + NL +
"HH:MM" + NL +
"HH:MM" + NL +
"HH:MM" + NL +
"HH:MM" + NL +
"HH:MM" + NL +
"HH:MM" + NL +
" " +
611 const AnsiString TTLabelStr5 =
"HH:MM ';' Location" + NL +
"HH:MM ';' HH:MM ';' Location";
613 const AnsiString TTLabelStr6 =
"+ rear element ID - space - front element ID [+ optional ';S']" + NL +
"+ ref. of the train that splits" + NL +
614 "+ other service ref." + NL +
"+ shuttle service ref." + NL +
"+ rear element ID - space - front element ID ';' linked shuttle ref." + NL +
615 "+ linked shuttle service ref. ';' feeder service ref." + NL +
"+ location" + NL +
"+ joining train ref." + NL +
"+ new service ref." + NL +
616 "+ new service ref." + NL +
" " + NL +
"+ new service ref." + NL +
"+ ref. of train to join" + NL +
617 "+ list of valid exit element IDs (at least 1) separated by spaces" + NL +
"+ linked shuttle service ref.";
619 const AnsiString TTLabelStr7 =
"Arrival OR departure time (program will determine which from the context) + location." + NL +
620 "Arrival time, departure time (with no events between) + location";
622 const AnsiString TTLabelStr9 =
"Timetable entries" + NL +
"(service references etc.)";
623 const AnsiString TTLabelStr11 =
"Timetable" + NL +
"start time";
625 const AnsiString TTLabelStr12 =
"NB: WITHIN SERVICES commas must" + NL +
"not be used (have special meanings)," + NL +
626 "and semicolons may only be used to" + NL +
"separate service components.";
628 const AnsiString TTLabelStr13 =
"+ linked shuttle service ref. ';' finishing service ref." + NL +
"+ linked shuttle service ref.";
630 const AnsiString TTLabelStr15 =
"Repeat the service + ';' minutes between repeats ';' digit increment ';' number of repeats (last line of service)";
632 TTLabel1->Caption = TTLabelStr1;
633 TTLabel2->Caption = TTLabelStr2;
634 TTLabel3->Caption = TTLabelStr3;
635 TTLabel4->Caption = TTLabelStr4;
636 TTLabel5->Caption = TTLabelStr5;
637 TTLabel6->Caption = TTLabelStr6;
638 TTLabel7->Caption = TTLabelStr7;
639 TTLabel9->Caption = TTLabelStr9;
640 TTLabel11->Caption = TTLabelStr11;
641 TTLabel12->Caption = TTLabelStr12;
642 TTLabel13->Caption = TTLabelStr13;
643 TTLabel15->Caption = TTLabelStr15;
651 MainScreen->Canvas->FillRect(MainScreen->ClientRect);
653 if((Screen->Width < 1024) || (Screen->Height < 768))
655 ShowMessage(
"Please note that this program works best with a screen resolution of at least 1024 x 768. Please change if possible");
657 SkipFormResizeEvent =
true;
658 MasterClock->Enabled =
true;
660 WindowState = wsMaximized;
661 MTBFEditBox->Left = MainScreen->Left + MainScreen->Width - MTBFEditBox->Width + 30;
663 MTBFLabel->Left = MainScreen->Left + MainScreen->Width - MTBFEditBox->Width + 30 - 55;
664 PositionalPanel->Left = MainScreen->Left + MainScreen->Width;
665 PositionalPanel->Top = MainScreen->Top;
666 PositionalPanel->Height = MainScreen->Height;
670 Level1Mode = BaseMode;
672 Screen->Cursor = TCursor(-2);
673 SkipFormResizeEvent =
false;
674 SelectedGraphicFileName =
"";
676 FloatingPanel->Color = TColor(0xF0FFFF);
677 PerformancePanel->Color = TColor(0xCCCCCC);
678 OperatorActionPanel->Color = TColor(0xCCCCCC);
679 DevelopmentPanel->Color = TColor(0xCCCCCC);
680 TTStartTimeBox->Color = TColor(0x99FFFF);
681 HighlightPanel->Color = TColor(0x33CCFF);
683 MTBFEditBox->Visible =
false;
684 MTBFLabel->Visible =
false;
688 CancelSelectionFlag =
false;
690 TTFirstServicePtr = 0;
691 TTLastServicePtr = 0;
693 ConflictPanel->Visible =
false;
694 TTClockAdjustWarningPanel->Visible =
false;
695 TTClockAdjustWarningHide =
false;
696 TwoLocationNamePanel->Visible =
false;
697 TwoLocationNamePanelHide =
false;
698 LastNonCtrlOrShiftKeyDown = -1;
699 ClipboardChecked =
false;
700 MMoveTrackSelFlag =
false;
701 MMovePrefDirSelFlag =
false;
702 MMoveCopyCutSelPickedUpFlag =
false;
703 MMoveTextGraphicTextFoundFlag =
false;
704 MMoveTextGraphicUserGraphicFoundFlag =
false;
706 SigImagePanel->Left = (
Interface->Width - SigImagePanel->Width) / 2;
710 char *LocalNumericInformation = setlocale(LC_NUMERIC,
"");
712 if(LocalNumericInformation ==
"")
717 struct lconv *conv = &Locale;
723 catch(
const EFOpenError &e)
727 MessageDlg(e.Message +
" - program must terminate", mtError, But, 0);
728 Application->Terminate();
731 catch(
const Exception &e)
735 AnsiString Message =
"A fatal error occurred during the program setup process, the program must terminate. Message = " + e.Message;
736 MessageDlg(Message, mtError, But, 0);
737 ErrorLog(115, e.Message);
738 Application->Terminate();
750 AnsiString ColourStr =
"", SignalStr =
"";
751 remove((
CurDir +
"\\Config.txt").c_str());
752 std::ofstream ConfigFile((
CurDir +
"\\Config.txt").c_str());
767 ConfigFile << AnsiString(
"Signals=") << SignalStr <<
'\n';
768 ConfigFile << AnsiString(
"BgndCol=") << ColourStr <<
'\n';
769 ConfigFile << AnsiString(
"RLYLocn=") << AnsiString(
LoadRailwayDialog->InitialDir) <<
'\n';
770 ConfigFile << AnsiString(
"TTBLocn=") << AnsiString(
TimetableDialog->InitialDir) <<
'\n';
771 ConfigFile << AnsiString(
"SSNLocn=") << AnsiString(
LoadSessionDialog->InitialDir) <<
'\n';
796 catch(
const Exception &e)
813 catch(
const Exception &e)
834 Screen->Cursor = TCursor(-2);
844 Screen->Cursor = TCursor(-2);
852 catch(
const Exception &e)
871 catch(
const Exception &e)
884 UnicodeString strVersion = L
"N/A";
886 VersionSize = GetFileVersionInfoSizeW(Application->ExeName.c_str(), &VersionHandle);
889 pBuffer =
new BYTE[VersionSize];
891 if(GetFileVersionInfoW(Application->ExeName.c_str(), VersionHandle, VersionSize, pBuffer))
893 VS_FIXEDFILEINFO *fi;
897 if(VerQueryValueW(pBuffer, L
"\\", (
void**)&fi, &buflen))
900 strVersion.sprintf(L
"%d.%d.%d", HIWORD(fi->dwFileVersionMS), LOWORD(fi->dwFileVersionMS), HIWORD(fi->dwFileVersionLS));
906 return(L
" v" + strVersion);
922 catch(
const Exception &e)
941 catch(
const Exception &e)
955 if(((TSpeedButton*)Sender)->Down)
966 Screen->Cursor = TCursor(-11);
967 InfoPanel->Caption =
"SELECTING: Filling area with chosen element";
968 bool FillSelectionFlag =
false;
971 UnicodeString MessageStr =
972 "Click 'Yes' to fill the area with the chosen element or 'No' to abort.\n" "Existing elements won't be overwritten although track can\n"
973 "have platforms and non-station named location elements added.\n\nThis message will not be shown again.";
974 int button = Application->MessageBox(MessageStr.c_str(), L
"", MB_YESNO);
977 FillSelectionFlag =
true;
982 bool TrackLinkingRequiredFlag =
true;
1011 Screen->Cursor = TCursor(-2);
1022 catch(
const Exception &e)
1064 ShowMessage(
"Incomplete track or other error - see inverted element (may be behind this message)");
1076 ShowMessage(
"Unable to set any track links");
1103 ShowMessage(
"Successful Completion");
1106 catch(
const Exception &e)
1127 catch(
const Exception &e)
1146 catch(
const Exception &e)
1165 catch(
const Exception &e)
1184 TFont *TempFont =
new TFont;
1192 TempText.
Font = DisplayFont;
1200 else if(Key ==
'\x1B')
1210 catch(
const Exception &e)
1229 catch(
const Exception &e)
1244 ShowMessage(
"Error, location name being entered without an entry in LNPendingList");
1264 Screen->Cursor = TCursor(-11);
1267 AnsiString ExistingName;
1281 UnicodeString MessageStr = UnicodeString(
"Another location named '") +
LocationNameTextBox->Text +
1282 UnicodeString(
"' already exists. If you continue its name will be erased. Do you wish to continue?");
1283 int button = Application->MessageBox(MessageStr.c_str(), L
"Warning!", MB_YESNO | MB_ICONWARNING);
1287 Screen->Cursor = TCursor(-2);
1298 bool UseExistingPosition =
false;
1307 if(ExistingName !=
"")
1311 UseExistingPosition =
true;
1315 Screen->Cursor = TCursor(-2);
1330 bool UseExistingPosition =
false;
1333 UseExistingPosition =
true;
1337 Screen->Cursor = TCursor(-2);
1350 LocStr = LocStr.Trim();
1359 if((LocStr !=
"") && (LocStr[1] >=
'0') && (LocStr[1] <=
'9'))
1361 Screen->Cursor = TCursor(-2);
1362 ShowMessage(
"Location name can't begin with a number");
1370 if(LocStr.Length() > 50)
1372 Screen->Cursor = TCursor(-2);
1373 ShowMessage(
"Location name too long, 50 characters maximum");
1381 for(
int x = 1; x <= LocStr.Length(); x++)
1383 char Ch = LocStr[x];
1384 if((Ch !=
' ') && (Ch !=
'&') && (Ch !=
'(') && (Ch !=
')') && (Ch !=
':') && (Ch != 39) && (Ch !=
'.') && (Ch !=
'-') && (Ch !=
'+') &&
1385 (Ch !=
'/') && ((Ch <
'0') || (Ch >
'9')) && ((Ch <
'A') || (Ch >
'Z')) && ((Ch <
'a') || (Ch >
'z')))
1387 Screen->Cursor = TCursor(-2);
1389 "Location name contains one or more invalid characters, must be alphanumeric, brackets, space, full stop, colon, inverted comma, '-', '+', '/' or '&&'");
1400 Screen->Cursor = TCursor(-2);
1401 ShowMessage(
"Location name cannot be 'cdt', this name would interfere with the timetable");
1412 bool UseExistingPosition =
false;
1413 if(ExistingName !=
"")
1417 UseExistingPosition =
true;
1421 Screen->Cursor = TCursor(-2);
1430 Screen->Cursor = TCursor(-2);
1433 catch(
const Exception &e)
1454 catch(
const Exception &e)
1468 int Dist = 0, SpeedLimit = 0;
1472 DistanceStr =
"No change";
1477 SpeedStr =
"No change";
1481 if(DistanceStr ==
"No change")
1485 if(SpeedStr ==
"No change")
1501 if(((Dist != -1) && (DistanceStr.Length() > 6)) || ((SpeedLimit != -1) && (SpeedStr.Length() > 6)))
1503 ShowMessage(
"One or more entries too long");
1507 if((DistanceStr ==
"") || (SpeedStr ==
""))
1509 ShowMessage(
"One or more entries blank");
1515 for(
int x = 1; x <= DistanceStr.Length(); x++)
1517 if((DistanceStr[x] <
'0') || (DistanceStr[x] >
'9'))
1519 ShowMessage(
"Track length value must be a positive whole number, or blank for no change");
1527 for(
int x = 1; x <= DistanceStr.Length(); x++)
1529 if((DistanceStr[x] <
'0') || (DistanceStr[x] >
'9'))
1531 ShowMessage(
"Distance must be a positive whole number");
1539 for(
int x = 1; x <= SpeedStr.Length(); x++)
1541 if((SpeedStr[x] <
'0') || (SpeedStr[x] >
'9'))
1543 ShowMessage(
"Speed limit must be a positive whole number, or blank for no change");
1551 for(
int x = 1; x <= SpeedStr.Length(); x++)
1553 if((SpeedStr[x] <
'0') || (SpeedStr[x] >
'9'))
1555 ShowMessage(
"Speed limit must be a positive whole number, or 'Mixed'");
1563 Dist = DistanceStr.ToInt();
1565 if(SpeedLimit != -1)
1567 SpeedLimit = SpeedStr.ToInt();
1576 if(((Dist != -1) && (Dist < 20)) || ((SpeedLimit != -1) && (SpeedLimit < 10)) || ((SpeedLimit != -1) && (SpeedLimit >
TTrain::MaximumSpeedLimit)))
1579 ShowMessage(
"Lengths must be 20m or more, and speeds must be between 10km/h and 400km/h");
1592 bool NamedLocPresent =
false;
1595 for(
int x = LowSelectHLoc; x < HighSelectHLoc; x++)
1597 for(
int y = LowSelectVLoc; y < HighSelectVLoc; y++)
1601 NamedLocPresent =
true;
1606 if(NamedLocPresent && (Dist < 50))
1610 ShowMessage(
"Note: Named location elements are quite short. If they are too short the simulation might be too unrealistic.\n\nThis message will not be shown again.");
1614 if(NamedLocPresent && (Dist > 200))
1618 ShowMessage(
"Note: Named location elements are quite long. If they are too long the simulation might be too unrealistic.\n\nThis message will not be shown again.");
1622 for(
int x = LowSelectHLoc; x < HighSelectHLoc; x++)
1624 for(
int y = LowSelectVLoc; y < HighSelectVLoc; y++)
1661 catch(
const Exception &e)
1684 catch(
const Exception &e)
1696 TMsgDlgButtons Buttons;
1697 Buttons << mbYes << mbNo;
1698 if(MessageDlg(
"This will reset the selected elements to default lengths & speed limits. Proceed?", mtWarning, Buttons, 0) == mrNo)
1717 for(
int x = LowSelectHLoc; x < HighSelectHLoc; x++)
1719 for(
int y = LowSelectVLoc; y < HighSelectVLoc; y++)
1773 throw Exception(
"Error, XLinkPos > 1 in SetOneDefaultTrackLength at " + AnsiString(TrackElement.
HLoc) +
" & " +
1774 AnsiString(TrackElement.
VLoc));
1790 catch(
const Exception &e)
1802 TMsgDlgButtons Buttons;
1803 Buttons << mbYes << mbNo;
1804 if(MessageDlg(
"This will reset ALL track elements to default lengths & speed limits. Proceed?", mtWarning, Buttons, 0) == mrNo)
1826 catch(
const Exception &e)
1854 bool GraphicFoundInVector =
false;
1855 for(TTrack::TUserGraphicVector::iterator UGVIt =
Track->
UserGraphicVector.begin(); UGVIt < Track->UserGraphicVector.end(); UGVIt++)
1857 if(UGMIt->first == UGVIt->FileName)
1859 GraphicFoundInVector =
true;
1863 if(!GraphicFoundInVector)
1865 delete UGMIt->second;
1881 catch(
const Exception &e)
1921 catch(
const Exception &e)
1960 catch(
const Exception &e)
1990 catch(
const Exception &e)
2016 catch(
const Exception &e)
2035 catch(
const Exception &e)
2050 ShowMessage(
"No preferred direction selection");
2054 Screen->Cursor = TCursor(-11);
2061 Screen->Cursor = TCursor(-2);
2064 catch(
const Exception &e)
2077 TMsgDlgButtons Buttons;
2078 Buttons << mbYes << mbNo;
2079 if(MessageDlg(
"Do you really want to clear all preferred directions?", mtWarning, Buttons, 0) == mrNo)
2095 catch(
const Exception &e)
2110 Screen->Cursor = TCursor(-11);
2119 Screen->Cursor = TCursor(-2);
2122 catch(
const Exception &e)
2140 catch(
const Exception &e)
2161 catch(
const Exception &e)
2186 catch(
const Exception &e)
2212 InfoPanel->Caption =
"PRE-START: Select AUTOMATIC SIGNAL ROUTE start signal, or left click points to change manually";
2216 InfoPanel->Caption =
"OPERATING: Select AUTOMATIC SIGNAL ROUTE start signal, or left click points to change manually";
2225 catch(
const Exception &e)
2252 InfoPanel->Caption =
"PRE-START: Select PREFERRED ROUTE start signal, or left click points to change manually";
2256 InfoPanel->Caption =
"OPERATING: Select PREFERRED ROUTE start signal, or left click points to change manually";
2265 catch(
const Exception &e)
2292 InfoPanel->Caption =
"PRE-START: Select PREFERRED ROUTE start signal, or left click points to change manually";
2296 InfoPanel->Caption =
"OPERATING: Select PREFERRED ROUTE start signal, or left click points to change manually";
2305 catch(
const Exception &e)
2338 InfoPanel->Caption =
"PRE-START: Select UNRESTRICTED ROUTE start location, or left click points to change manually";
2342 InfoPanel->Caption =
"OPERATING: Select UNRESTRICTED ROUTE start location, or left click points to change manually";
2351 catch(
const Exception &e)
2366 InfoPanel->Caption =
"ROUTE CANCELLING: Right click on truncate element, first element to cancel (anywhere else to skip)";
2373 catch(
const Exception &e)
2400 catch(
const Exception &e)
2415 UnicodeString MessageStr =
"Please note that the session will be lost if it hasn't been saved. Do you still wish to exit?";
2418 int button = Application->MessageBox(MessageStr.c_str(), L
"Please confirm", MB_YESNO);
2457 catch(
const Exception &e)
2499 catch(
const Exception &e)
2512 Screen->Cursor = TCursor(-11);
2513 std::ifstream VecFile(LoadFileName.c_str());
2514 if(!(VecFile.fail()))
2519 bool GraphicsFollow =
false;
2538 TFont *TempFont =
new TFont;
2539 TempFont->Style.Clear();
2540 TempFont->Name =
"MS Sans Serif";
2541 TempFont->Size = 10;
2543 TempFont->Charset = (TFontCharset)(0);
2552 if((LeftExcess > 0) && (RightExcess > 0))
2556 else if((LeftExcess > 0) && (RightExcess <= 0))
2561 else if((LeftExcess <= 0) && (RightExcess > 0))
2573 if((TopExcess > 0) && (BotExcess > 0))
2577 else if((TopExcess > 0) && (BotExcess <= 0))
2582 else if((TopExcess <= 0) && (BotExcess > 0))
2599 if((LastChar ==
'y') || (LastChar ==
'Y'))
2603 ShowMessage(
"Railway not ready for operation so unable to load as a .rly file. Loading as a new railway under development");
2610 Screen->Cursor = TCursor(-2);
2645 ShowMessage(
"File open failed prior to load");
2647 Screen->Cursor = TCursor(-2);
2651 ShowMessage(
"File integrity check failed - unable to load " + LoadFileName +
". Please check that the file exists and is spelled correctly.");
2668 Screen->Cursor = TCursor(-11);
2670 if(!(VecFile.fail()))
2698 ShowMessage(
"File open failed prior to save");
2700 Screen->Cursor = TCursor(-2);
2705 catch(
const Exception &e)
2721 catch(
const Exception &e)
2738 ShowMessage(
"Failed to find folder " +
IMAGE_DIR_NAME +
" in the folder where 'railway.exe' resides. Image can't be saved");
2742 Screen->Cursor = TCursor(-11);
2745 AnsiString ImageFileName = TDateTime::CurrentDateTime().FormatString(
"dd-mm-yyyy hh.nn.ss");
2749 AnsiString ShortName =
"";
2750 for(
int x = ImageFileName.Length(); x > 0; x--)
2752 if(ImageFileName[x] ==
'\\')
2754 ShortName = ImageFileName.SubString(x + 1, ImageFileName.Length() - x - 4);
2758 ShowMessage(
"A bitmap file named " + ShortName +
" will be created in the Images folder");
2759 Graphics::TBitmap *RailwayImage =
new Graphics::TBitmap;
2760 RailwayImage->PixelFormat = pf8bit;
2766 RailwayImage->Width = HPosMax - HPosMin;
2767 RailwayImage->Height = VPosMax - VPosMin;
2775 int NewWidth = (TextPtr->HPos - HPosMin) + (abs(TextPtr->Font->Height) * TextPtr->TextString.Length() * 0.7);
2776 int NewHeight = (TextPtr->VPos - VPosMin) + (abs(TextPtr->Font->Height) * 1.5);
2777 if(NewWidth > RailwayImage->Width)
2779 RailwayImage->Width = NewWidth;
2781 if(NewHeight > RailwayImage->Height)
2783 RailwayImage->Height = NewHeight;
2787 RailwayImage->Canvas->Brush->Color =
clB5G5R5;
2788 TRect Rect(0, 0, RailwayImage->Width, RailwayImage->Height);
2789 RailwayImage->Canvas->FillRect(Rect);
2796 RailwayImage->SaveToFile(ImageFileName);
2797 delete RailwayImage;
2800 Screen->Cursor = TCursor(-2);
2803 catch(
const Exception &e)
2805 if(e.Message.Pos(
"torage") > 0)
2807 Screen->Cursor = TCursor(-2);
2808 UnicodeString MessageStr =
"Insufficient memory available to store this image";
2809 Application->MessageBox(MessageStr.c_str(), L
"", MB_OK | MB_ICONWARNING);
2830 ShowMessage(
"Failed to find folder " +
IMAGE_DIR_NAME +
" in the folder where 'railway.exe' resides. Image can't be saved");
2834 Screen->Cursor = TCursor(-11);
2837 AnsiString ImageFileName = TDateTime::CurrentDateTime().FormatString(
"dd-mm-yyyy hh.nn.ss");
2841 AnsiString ShortName =
"";
2842 for(
int x = ImageFileName.Length(); x > 0; x--)
2844 if(ImageFileName[x] ==
'\\')
2846 ShortName = ImageFileName.SubString(x + 1, ImageFileName.Length() - x - 4);
2850 ShowMessage(
"A bitmap file named " + ShortName +
" will be created in the Images folder");
2851 Graphics::TBitmap *RailwayImage =
new Graphics::TBitmap;
2852 RailwayImage->PixelFormat = pf8bit;
2857 RailwayImage->Width = HPosMax - HPosMin;
2858 RailwayImage->Height = VPosMax - VPosMin;
2866 int NewWidth = (TextPtr->HPos - HPosMin) + (abs(TextPtr->Font->Height) * TextPtr->TextString.Length() * 0.7);
2867 int NewHeight = (TextPtr->VPos - VPosMin) + (abs(TextPtr->Font->Height) * 1.5);
2868 if(NewWidth > RailwayImage->Width)
2870 RailwayImage->Width = NewWidth;
2872 if(NewHeight > RailwayImage->Height)
2874 RailwayImage->Height = NewHeight;
2878 RailwayImage->Canvas->Brush->Color =
clB5G5R5;
2879 TRect Rect(0, 0, RailwayImage->Width, RailwayImage->Height);
2880 RailwayImage->Canvas->FillRect(Rect);
2883 for(
int x = 0; x < ((RailwayImage->Width) / 16); x++)
2885 for(
int y = 0; y < ((RailwayImage->Height) / 16); y++)
2894 RailwayImage->SaveToFile(ImageFileName);
2895 delete RailwayImage;
2898 Screen->Cursor = TCursor(-2);
2901 catch(
const Exception &e)
2903 if(e.Message.Pos(
"torage") > 0)
2905 Screen->Cursor = TCursor(-2);
2906 UnicodeString MessageStr =
"Insufficient memory available to store this image";
2907 Application->MessageBox(MessageStr.c_str(), L
"", MB_OK | MB_ICONWARNING);
2927 ShowMessage(
"Failed to find folder " +
IMAGE_DIR_NAME +
" in the folder where 'railway.exe' resides. Image can't be saved");
2931 Screen->Cursor = TCursor(-11);
2934 AnsiString ImageFileName = TDateTime::CurrentDateTime().FormatString(
"dd-mm-yyyy hh.nn.ss");
2938 AnsiString ShortName =
"";
2939 for(
int x = ImageFileName.Length(); x > 0; x--)
2941 if(ImageFileName[x] ==
'\\')
2943 ShortName = ImageFileName.SubString(x + 1, ImageFileName.Length() - x - 4);
2947 ShowMessage(
"A bitmap file named " + ShortName +
" will be created in the Images folder");
2948 Graphics::TBitmap *RailwayImage =
new Graphics::TBitmap;
2949 RailwayImage->PixelFormat = pf8bit;
2954 RailwayImage->Width = HPosMax - HPosMin;
2955 RailwayImage->Height = VPosMax - VPosMin;
2963 int NewWidth = (TextPtr->HPos - HPosMin) + (abs(TextPtr->Font->Height) * TextPtr->TextString.Length() * 0.7);
2964 int NewHeight = (TextPtr->VPos - VPosMin) + (abs(TextPtr->Font->Height) * 1.5);
2965 if(NewWidth > RailwayImage->Width)
2967 RailwayImage->Width = NewWidth;
2969 if(NewHeight > RailwayImage->Height)
2971 RailwayImage->Height = NewHeight;
2975 RailwayImage->Canvas->Brush->Color =
clB5G5R5;
2976 TRect Rect(0, 0, RailwayImage->Width, RailwayImage->Height);
2977 RailwayImage->Canvas->FillRect(Rect);
2984 RailwayImage->SaveToFile(ImageFileName);
2985 delete RailwayImage;
2988 Screen->Cursor = TCursor(-2);
2991 catch(
const Exception &e)
2993 if(e.Message.Pos(
"torage") > 0)
2995 Screen->Cursor = TCursor(-2);
2996 UnicodeString MessageStr =
"Insufficient memory available to store this image";
2997 Application->MessageBox(MessageStr.c_str(), L
"", MB_OK | MB_ICONWARNING);
3017 ShowMessage(
"Failed to find folder " +
IMAGE_DIR_NAME +
" in the folder where 'railway.exe' resides. Image can't be saved");
3021 Screen->Cursor = TCursor(-11);
3026 TimetableTimeStr = TimetableTimeStr.SubString(1, 2) +
'.' + TimetableTimeStr.SubString(4, 2) +
'.' + TimetableTimeStr.SubString(7, 2);
3027 AnsiString ImageFileName = TDateTime::CurrentDateTime().FormatString(
"dd-mm-yyyy hh.nn.ss");
3032 AnsiString ShortName =
"";
3033 for(
int x = ImageFileName.Length(); x > 0; x--)
3035 if(ImageFileName[x] ==
'\\')
3037 ShortName = ImageFileName.SubString(x + 1, ImageFileName.Length() - x - 4);
3041 ShowMessage(
"A bitmap file named " + ShortName +
" will be created in the Images folder");
3042 Graphics::TBitmap *RailwayImage =
new Graphics::TBitmap;
3043 RailwayImage->PixelFormat = pf8bit;
3048 RailwayImage->Width = HPosMax - HPosMin;
3049 RailwayImage->Height = VPosMax - VPosMin;
3057 int NewWidth = (TextPtr->HPos - HPosMin) + (abs(TextPtr->Font->Height) * TextPtr->TextString.Length() * 0.7);
3058 int NewHeight = (TextPtr->VPos - VPosMin) + (abs(TextPtr->Font->Height) * 1.5);
3059 if(NewWidth > RailwayImage->Width)
3061 RailwayImage->Width = NewWidth;
3063 if(NewHeight > RailwayImage->Height)
3065 RailwayImage->Height = NewHeight;
3069 RailwayImage->Canvas->Brush->Color =
clB5G5R5;
3070 TRect Rect(0, 0, RailwayImage->Width, RailwayImage->Height);
3071 RailwayImage->Canvas->FillRect(Rect);
3085 bool BreakFlag =
false;
3111 RailwayImage->SaveToFile(ImageFileName);
3112 delete RailwayImage;
3115 Screen->Cursor = TCursor(-2);
3118 catch(
const Exception &e)
3120 if(e.Message.Pos(
"torage") > 0)
3122 Screen->Cursor = TCursor(-2);
3123 UnicodeString MessageStr =
"Insufficient memory available to store this image";
3124 Application->MessageBox(MessageStr.c_str(), L
"", MB_OK | MB_ICONWARNING);
3153 Screen->Cursor = TCursor(-11);
3155 if(!(VecFile.fail()))
3183 ShowMessage(
"Railway failed to save - can't open file");
3185 Screen->Cursor = TCursor(-2);
3189 catch(
const Exception &e)
3203 catch(
const Exception &e)
3225 catch(
const Exception &e)
3241 ShowMessage(
"Failed to find folder " +
FORMATTEDTT_DIR_NAME +
" in the folder where 'railway.exe' resides. Timetable can't be exported");
3249 Screen->Cursor = TCursor(-2);
3252 catch(
const Exception &e)
3312 AZOrderButton->Hint = AnsiString(
"Arrange services in alphabetical order Toggle with Shift+ Z");
3332 ActiveTrackElementNameMapEntry.second = 0;
3383 catch(
const Exception &e)
3432 if(TTBLFile.is_open())
3436 while(!TTBLFile.eof())
3439 if((c < 32) && (c != 13) && (c != 10) && (c !=
'\0'))
3441 ShowMessage(
"Timetable file is empty or contains non-ascii characters, codes must be between 20 and 127, or CR or LF");
3451 ShowMessage(
"Failed to open timetable file " +
CreateEditTTFileName +
", make sure it's spelled correctly, it exists and isn't open in another application");
3458 if(TTBLFile.is_open())
3467 AZOrderButton->Hint = AnsiString(
"Arrange services in alphabetical order Toggle with Shift+ Z");
3480 char *TimetableEntryString =
new char[10000];
3483 TTBLFile.getline(TimetableEntryString, 10000,
'\0');
3484 if(TTBLFile.eof() && (TimetableEntryString[0] ==
'\0'))
3490 AnsiString OneLine(TimetableEntryString);
3494 delete[] TimetableEntryString;
3499 ShowMessage(
"Failed to open timetable file " +
CreateEditTTFileName +
", make sure it's spelled correctly, it exists and isn't open in another application");
3535 ActiveTrackElementNameMapEntry.second = 0;
3561 catch(
const Exception &e)
3580 InfoPanel->Caption =
"Timetable mode: editor hidden";
3587 ShowHideTTButton->Hint =
"Hide the timetable editor to see the railway Shift H";
3592 catch(
const Exception &e)
3633 catch(
const Exception &e)
3674 catch(
const Exception &e)
3694 catch(
const Exception &e)
3707 bool ValidFlag =
true;
3728 TDateTime DummyTime;
3746 ShowMessage(
"One or more times excessive, not permitted to exceed 95 hours");
3750 AnsiString MinsStr = AnsiString(Mins), HrsStr = AnsiString(Hrs);
3753 MinsStr =
"0" + MinsStr;
3757 HrsStr =
"0" + HrsStr;
3761 NewString += HrsStr +
':' + MinsStr;
3778 catch(
const Exception &e)
3791 bool ValidFlag =
true;
3812 TDateTime DummyTime;
3830 ShowMessage(
"One or more times are now before 00:00, this is not permitted");
3834 AnsiString MinsStr = AnsiString(Mins), HrsStr = AnsiString(Hrs);
3837 MinsStr =
"0" + MinsStr;
3841 HrsStr =
"0" + HrsStr;
3845 NewString += HrsStr +
':' + MinsStr;
3861 catch(
const Exception &e)
3899 catch(
const Exception &e)
3944 if(OldVectorPos == 0)
3972 catch(
const Exception &e)
4031 catch(
const Exception &e)
4049 UnicodeString MessageStr =
"Are you sure this entry should be deleted?";
4050 int button = Application->MessageBox(MessageStr.c_str(), L
"Please confirm", MB_YESNO);
4082 if(OldVectorPos == 0)
4110 catch(
const Exception &e)
4131 AnsiString TempStr =
"";
4132 bool ActiveLine =
false;
4157 while(TempStr[TempStr.Length()] ==
',')
4159 TempStr = TempStr.SubString(1, TempStr.Length() - 1);
4190 (*TTCurrentEntryPtr) = TempStr;
4260 catch(
const Exception &e)
4275 ShowMessage(
"Timetable is empty, can't save an empty timetable");
4279 std::ofstream TTBLFile;
4314 if(TTBLFile.is_open())
4318 TTBLFile << (*TEVPtr).c_str() <<
'\0';
4325 ShowMessage(
CreateEditTTFileName +
" failed to open, ensure not already open in another application");
4331 catch(
const Exception &e)
4346 ShowMessage(
"Timetable is empty, can't save an empty timetable");
4350 std::ofstream TTBLFile;
4359 for(
int x =
SaveTTDialog->FileName.Length(); x > 0; x--)
4377 if(TTBLFile.is_open())
4381 TTBLFile << (*TEVPtr).c_str() <<
'\0';
4388 ShowMessage(
CreateEditTTFileName +
" failed to open, ensure not already open in another application");
4394 catch(
const Exception &e)
4408 bool EndOfFile =
false;
4409 bool FinalCallFalse =
false;
4410 bool GiveMessagesTrue =
true;
4411 bool CheckLocationsExistInRailway =
false;
4414 CheckLocationsExistInRailway =
true;
4421 "The basic syntax seems OK but this check is very limited. Other aspects can only be checked by validating the whole timetable with the appropriate railway (.rly) loaded");
4427 catch(
const Exception &e)
4455 bool CheckLocationsExistInRailwayTrue =
true;
4458 Screen->Cursor = TCursor(-11);
4460 if(TTBLFile.is_open())
4466 ShowMessage(
"Timetable integrity OK");
4474 ShowMessage(
"Failed to open timetable file, make sure it's spelled correctly, it exists and isn't open in another application");
4476 Screen->Cursor = TCursor(-2);
4486 catch(
const Exception &e)
4510 AnsiString TempStr = *
TEVPtr;
4548 catch(
const Exception &e)
4572 AnsiString TempStr = *
TEVPtr;
4610 catch(
const Exception &e)
4647 catch(
const Exception &e)
4662 UnicodeString MessageStr =
"All changes to the timetable will be lost - proceed?";
4663 int button = Application->MessageBox(MessageStr.c_str(), L
"Please confirm", MB_YESNO);
4673 if(TTBLFile.is_open())
4690 char *TimetableEntryString =
new char[10000];
4693 TTBLFile.getline(TimetableEntryString, 10000,
'\0');
4694 if(TTBLFile.eof() && (TimetableEntryString[0] ==
'\0'))
4700 AnsiString OneLine(TimetableEntryString);
4704 delete[] TimetableEntryString;
4709 ShowMessage(
"Failed to open timetable file, make sure it's spelled correctly, it exists and isn't open in another application");
4729 catch(
const Exception &e)
4744 ShowMessage(
"Failed to find folder " +
FORMATTEDTT_DIR_NAME +
" in the folder where 'railway.exe' resides. Timetable can't be exported");
4763 Screen->Cursor = TCursor(-2);
4768 catch(
const Exception &e)
4801 catch(
const Exception &e)
4816 UnicodeString MessageStr =
"The timetable has changed.\n\nAre you sure you want to exit without saving it?";
4817 int button = Application->MessageBox(MessageStr.c_str(), L
"Please confirm", MB_YESNO);
4833 catch(
const Exception &e)
4861 catch(
const Exception &e)
4886 catch(
const Exception &e)
4904 catch(
const Exception &e)
4927 catch(
const Exception &e)
4979 catch(
const Exception &e)
4992 TrainController->
LogEvent(
"OAListBoxMouseUp," + AnsiString(X) +
"," + AnsiString(Y) +
"," + AnsiString(Button));
4994 int ScreenPosH, ScreenPosV;
5005 int HPos, VPos, TrainID = -1, TrackVectorPosition = -1;
5012 if(Button == mbLeft)
5038 TPoint MainScreenPoint(ScreenPosH + 8, ScreenPosV + 8);
5039 TPoint CursPos =
MainScreen->ClientToScreen(MainScreenPoint);
5040 Mouse->CursorPos = CursPos;
5048 catch(
const Exception &e)
5062 if(Button == mbRight)
5068 catch(
const Exception &e)
5084 if((TopPos + (Y / 13)) >=
OAListBox->Items->Count)
5092 std::advance(OACurrentEntryPtr, ((Y / 13) + TopPos));
5094 int TrainIDorTVPos = OACurrentEntryPtr->second.second;
5095 if(TrainIDorTVPos >= 0)
5101 TrainID = TrainIDorTVPos;
5112 TrackVectorPosition = -(TrainIDorTVPos + 1);
5124 PreStartTime, ActiveSegment, PostEnd
5138 Segment = PreStartTime;
5141 if(Segment == PreStartTime)
5148 Segment = ActiveSegment;
5159 AnsiString CurrentStr = *
TEVPtr;
5160 if(CurrentStr !=
"")
5162 CurrentStr = CurrentStr.SubString(1, 10);
5163 for(
int x = 1; x < CurrentStr.Length(); x++)
5165 if((CurrentStr[x] < 32) || (CurrentStr[1] > 126))
5167 CurrentStr = CurrentStr.SubString(1, (x - 1));
5176 if(Segment == ActiveSegment)
5191 AnsiString Entry = *
TEVPtr;
5201 int SCPos = Entry.Pos(
';');
5202 int CPos = Entry.Pos(
',');
5209 if((CPos == 0) && (SCPos == 0))
5211 Entry = Entry.SubString(1, 12);
5213 else if((CPos > 0) && (SCPos > 0) && (CPos < SCPos))
5215 Entry = Entry.SubString(1, CPos - 1);
5217 else if((CPos > 0) && (SCPos > 0) && (CPos > SCPos))
5219 Entry = Entry.SubString(1, SCPos - 1);
5221 else if((CPos > 0) && (SCPos == 0))
5223 Entry = Entry.SubString(1, CPos - 1);
5227 Entry = Entry.SubString(1, SCPos - 1);
5240 if(Segment == PostEnd)
5248 AnsiString CurrentStr = *
TEVPtr;
5249 if(CurrentStr !=
"")
5251 CurrentStr = CurrentStr.SubString(1, 10);
5252 for(
int x = 1; x < CurrentStr.Length(); x++)
5254 if((CurrentStr[x] < 32) || (CurrentStr[1] > 126))
5256 CurrentStr = CurrentStr.SubString(1, (x - 1));
5287 UnicodeString MessageStr =
5288 "If you wish to preserve the original order don't save any changes whilst in alphabetical order.\n\n" "To preserve the original order use alphabetical order to find the service required, click it to display it,"
5289 " then revert to the original order where the same service will be displayed and can be changed.";
5290 Application->MessageBox(MessageStr.c_str(), L
"Please Note:", MB_OK | MB_ICONWARNING);
5303 std::sort(SortStart, SortEnd);
5305 bool CurrentEntryChanged =
false;
5311 CurrentEntryChanged =
true;
5314 if(!CurrentEntryChanged)
5319 AZOrderButton->Hint = AnsiString(
"Arrange services in original order Toggle with Shift+ Z");
5325 UnicodeString MessageStr =
5326 "Reverting to the original order will discard any changes made whilst in alphabetical order.\n\nTo preserve the changes click 'No', then save the timetable or use 'save as' if you wish to keep the original timetable.\n\nDo you wish to proceed?";
5327 int button = Application->MessageBox(MessageStr.c_str(), L
"Warning!", MB_YESNO | MB_ICONWARNING);
5341 bool CurrentEntryChanged =
false;
5347 CurrentEntryChanged =
true;
5350 if(!CurrentEntryChanged)
5355 AZOrderButton->Hint = AnsiString(
"Arrange services in alphabetical order Toggle with Shift+ Z");
5364 catch(
const Exception &e)
5375 AnsiString OutStr =
"";
5378 while(x < ConvStr.Length())
5380 if((ConvStr[x] ==
'\r') && (ConvStr[x + 1] ==
'\n'))
5388 OutStr += ConvStr[x];
5392 if(x == ConvStr.Length())
5394 OutStr += ConvStr[x];
5400 while(OutStr[OutStr.Length()] ==
',')
5402 OutStr = OutStr.SubString(1, OutStr.Length() - 1);
5476 InfoPanel->Caption =
"Select option or change entry";
5490 bool ValidFlag =
true;
5491 for(
int x = 1; x <= AnsiAddSubText.Length(); x++)
5493 if((AnsiAddSubText[x] >
'9') || (AnsiAddSubText[x] <
'0'))
5501 if(AnsiAddSubText.ToInt() != 0)
5574 bool ServiceEntry =
true;
5579 bool ServiceEntry =
false;
5591 InfoPanel->Caption =
"Add or change entry then save it, or cancel";
5601 AnsiString((
short)ServiceEntry));
5608 int CommaPos = Data.Pos(
',');
5609 if((CommaPos == 0) && (Data !=
""))
5611 CommaPos = Data.Length() + 1;
5614 if(Data.Length() <= CommaPos)
5618 Data = Data.SubString(CommaPos + 1, Data.Length() - CommaPos);
5657 if(CurrentStr !=
"")
5659 for(
int x = 1; x < CurrentStr.Length(); x++)
5661 if((CurrentStr[x] < 32) || (CurrentStr[1] > 126))
5663 CurrentStr = CurrentStr.SubString(1, (x - 1));
5696 TDateTime DummyTime;
5697 bool TimesPresent =
false;
5705 TimesPresent =
true;
5714 return(TimesPresent);
5741 UnicodeString MessageStr =
"The railway has changed, exit without saving?";
5742 int button = Application->MessageBox(MessageStr.c_str(), L
"Please confirm", MB_YESNO);
5754 Application->Terminate();
5756 catch(
const Exception &e)
5779 catch(
const Exception &e)
5802 catch(
const Exception &e)
5825 catch(
const Exception &e)
5902 catch(
const Exception &e)
5920 catch(
const Exception &e)
5939 catch(
const Exception &e)
5983 catch(
const Exception &e)
5994 TrainController->
LogEvent(
"MainScreenMouseDown2," + AnsiString(Button) +
"," + AnsiString(X) +
"," + AnsiString(Y));
5996 "," + AnsiString(Y));
6007 int NoOffsetX, NoOffsetY;
6009 if(Button == mbRight)
6013 AnsiString Text =
"";
6020 Screen->Cursor = TCursor(-22);
6076 bool TrackEraseSuccessfulFlag;
6077 int ErasedTrackVectorPosition;
6078 Screen->Cursor = TCursor(-11);
6080 if(TrackEraseSuccessfulFlag)
6082 if(ErasedTrackVectorPosition > -1)
6115 Screen->Cursor = TCursor(-2);
6123 bool LeadingPointsAtLastElement =
false;
6138 if(!LeadingPointsAtLastElement)
6143 InfoPanel->Caption =
"DISTANCE/SPEED SETTING: Continue or set values (overall length), or right click to cancel/truncate";
6162 InfoPanel->Caption =
"DISTANCE/SPEED SETTING: Can't end on leading points, continue or truncate";
6240 if((TrainID01 > -1) && (TrainID23 > -1))
6290 AnsiString LocName =
"";
6295 if((LocName ==
"") && (Train.
MidElement > -1))
6417 Screen->Cursor = TCursor(-11);
6428 Screen->Cursor = TCursor(-2);
6504 Screen->Cursor = TCursor(-11);
6506 bool TrackLinkingRequiredFlag;
6508 TSpeedButton *TempSpeedButton = 0;
6518 bool InternalChecks =
true;
6526 if(TrackLinkingRequiredFlag)
6555 Screen->Cursor = TCursor(-2);
6569 NewGI.
Width = UGMIt->second->Width;
6570 NewGI.
Height = UGMIt->second->Height;
6596 AnsiString NameString;
6606 unsigned int ValidPosition;
6617 ValidElement = InactiveTrackElement1;
6618 ValidPosition = InactivePair.first;
6623 ValidElement = InactiveTrackElement2;
6624 ValidPosition = InactivePair.second;
6635 InfoPanel->Caption =
"NAMING LOCATIONS: Enter name, 'Carriage Return' to accept, 'Escape' to quit";
6666 bool FinishElement =
false, LeadingPointsAtLastElement =
false;
6667 Screen->Cursor = TCursor(-11);
6682 InfoPanel->Caption =
"DISTANCE/SPEED SETTING: Set values (overall length), or right click to cancel/truncate";
6696 Screen->Cursor = TCursor(-2);
6702 if(!LeadingPointsAtLastElement)
6707 InfoPanel->Caption =
"DISTANCE/SPEED SETTING: Continue or set values (overall length), or right click to cancel/truncate";
6728 InfoPanel->Caption =
"DISTANCE/SPEED SETTING: Can't end on leading points, need to continue or truncate";
6743 Screen->Cursor = TCursor(-2);
6748 Screen->Cursor = TCursor(-2);
6766 InfoPanel->Caption =
"CONNECTING GAPS: Connecting element selected";
6778 ShowMessage(
"All gaps set");
6806 int TrueX = 0, TrueY = 0;
6807 AnsiString ExistingText =
"";
6809 TFont *ExistingTextFont =
new TFont;
6810 int ExistingTextHPos = 0, ExistingTextVPos = 0;
6816 if((TrueX >= TextPtr->HPos) && (TrueX < (TextPtr->HPos + abs(TextPtr->Font->Height))) && (TrueY >= TextPtr->VPos) && (TrueY <
6817 (TextPtr->VPos + abs(TextPtr->Font->Height))))
6819 ExistingText = TextPtr->TextString;
6820 ExistingTextFont->Assign(TextPtr->Font);
6821 ExistingTextHPos = TextPtr->HPos;
6822 ExistingTextVPos = TextPtr->VPos;
6835 TextBox->Font->Assign(ExistingTextFont);
6837 Text_X = ExistingTextHPos;
6838 Text_Y = ExistingTextVPos;
6856 TextBox->Text =
"New Text: CR=end, ESC=quit";
6860 delete ExistingTextFont;
6962 Screen->Cursor = TCursor(-11);
6973 ShowMessage(
"Preferred direction added");
6977 Screen->Cursor = TCursor(-2);
6996 Screen->Cursor = TCursor(-2);
7000 Screen->Cursor = TCursor(-2);
7097 AnsiString(PDE.
VLoc));
7111 bool PointsChanged =
false;
7112 IDInt ReqPosRouteID(-1);
7114 bool CallonTrue =
true;
7122 ReqPosRouteID, PointsChanged))
7164 float TempSpeedVal = 1;
7234 int DivergingPosition = TrackElement.
Conn[3];
7236 DivergingPosition)))
7265 bool TrainPresent =
false;
7269 int BDVectorPos = -1;
7279 TDateTime TempExcessLCDownTime;
7290 if(TempExcessLCDownTime > TDateTime(0))
7320 AnsiString Message =
7321 AnsiString(
"This will open the level crossing manually (it will show in green).\n\nA manually opened"
7322 " level crossing must be manually closed, and as soon as possible to avoid time penalties.\n\n" "This message will not be shown again."
7367 InfoPanel->Caption =
"PRE-START: Select next route location";
7371 InfoPanel->Caption =
"OPERATING: Select next route location";
7384 bool CallonFalse =
false;
7392 InfoPanel->Caption =
"PRE-START: Select next route location";
7396 InfoPanel->Caption =
"OPERATING: Select next route location";
7418 Screen->Cursor = TCursor(-11);
7420 bool PointsChanged =
false;
7430 float TempSpeedVal = 1;
7439 else if(PointsChanged)
7454 Screen->Cursor = TCursor(-2);
7462 bool CallonFalse =
false;
7467 float TempSpeedVal = 1;
7476 else if(PointsChanged)
7494 Screen->Cursor = TCursor(-2);
7502 catch(
const Exception &e)
7516 TrainController->
LogEvent(
"MainScreenMouseDown3," + AnsiString(Button) +
"," + AnsiString(X) +
"," + AnsiString(Y));
7518 "," + AnsiString(Y));
7519 if(Button != mbLeft)
7525 Screen->Cursor = TCursor(-22);
7531 int HRounding, VRounding;
7604 else if(TempLevel2OperMode ==
Operating)
7607 OperateButton->Glyph->LoadFromResourceName(0,
"PauseGraphic");
7611 else if(TempLevel2OperMode ==
Paused)
7614 OperateButton->Glyph->LoadFromResourceName(0,
"RunGraphic");
7620 else if(TempLevel2OperMode ==
PreStart)
7623 OperateButton->Glyph->LoadFromResourceName(0,
"RunGraphic");
7634 catch(
const Exception &e)
7735 if(CurrentHLoc >= StartHLoc)
7743 if(CurrentVLoc >= StartVLoc)
7767 TRect TempRect(StartHLoc, StartVLoc, CurrentHLoc, CurrentVLoc);
7785 if(CurrentHLoc >= StartHLoc)
7793 if(CurrentVLoc >= StartVLoc)
7817 TRect TempRect(StartHLoc, StartVLoc, CurrentHLoc, CurrentVLoc);
7896 catch(
const Exception &e)
7932 TrainController->
LogEvent(
"MainScreenMouseUp," + AnsiString(Button) +
"," + AnsiString(X) +
"," + AnsiString(Y));
7935 Screen->Cursor = TCursor(-2);
7945 Screen->Cursor = TCursor(-11);
7950 if(EndHLoc >= StartHLoc)
7958 if(EndVLoc >= StartVLoc)
7966 if(StartHLoc >= EndHLoc)
7976 if(StartVLoc >= EndVLoc)
8013 Screen->Cursor = TCursor(-2);
8085 if(IATVecPair.second != IATVecPair.first)
8095 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
8105 if(PrefDirPos0 > -1)
8110 if(PrefDirPos1 > -1)
8115 if(PrefDirPos2 > -1)
8120 if(PrefDirPos3 > -1)
8139 if((TextPtr->HPos >= LowSelectHPos) && (TextPtr->HPos < HighSelectHPos) && (TextPtr->VPos >= LowSelectVPos) && (TextPtr->VPos <
8147 bool SelectVectorNamedElement =
false;
8148 AnsiString SelectTextString;
8153 SelectVectorNamedElement =
true;
8157 if(SelectVectorNamedElement)
8159 SelectTextString =
"##**" + TextPtr->TextString;
8163 SelectTextString = TextPtr->TextString;
8165 TTextItem TextItem(TextPtr->HPos, TextPtr->VPos, SelectTextString, TextPtr->Font);
8174 for(TTrack::TUserGraphicVector::iterator UserGraphicPtr =
Track->
UserGraphicVector.begin(); UserGraphicPtr < Track->UserGraphicVector.end();
8177 if((UserGraphicPtr->HPos >= LowSelectHPos) && ((UserGraphicPtr->HPos + UserGraphicPtr->Width) < HighSelectHPos) &&
8178 (UserGraphicPtr->VPos >= LowSelectVPos) && ((UserGraphicPtr->VPos + UserGraphicPtr->Height) < HighSelectVPos))
8191 Screen->Cursor = TCursor(-2);
8197 Screen->Cursor = TCursor(-11);
8203 if(EndHLoc >= StartHLoc)
8211 if(EndVLoc >= StartVLoc)
8219 if(StartHLoc >= EndHLoc)
8229 if(StartVLoc >= EndVLoc)
8262 Screen->Cursor = TCursor(-2);
8294 Screen->Cursor = TCursor(-2);
8319 catch(
const Exception &e)
8357 throw Exception(
"Warning - Utilities->CallLog contains more than 50 items");
8382 catch(
const Exception &e)
8479 if(
WholeRailwayMoving && (GetAsyncKeyState(VK_LBUTTON) >= 0) && (GetAsyncKeyState(VK_RBUTTON) >= 0))
8482 Screen->Cursor = TCursor(-2);
8507 bool TrainPresent =
false;
8524 TDateTime TempExcessLCDownTime;
8533 if(TempExcessLCDownTime > TDateTime(0))
8562 bool ElementRemovedFlag =
false;
8579 int RouteNumber1, RouteNumber2, TrainID;
8587 ElementRemovedFlag =
true;
8603 bool WH1 = (Mouse->CursorPos.x >= ClientOrigin.x +
OutputLog1->Left) && (Mouse->CursorPos.x < (ClientOrigin.x +
OutputLog1->Width +
OutputLog1->Left))
8606 bool WH2 = (Mouse->CursorPos.x >= ClientOrigin.x +
OutputLog2->Left) && (Mouse->CursorPos.x < (ClientOrigin.x +
OutputLog2->Width +
OutputLog2->Left))
8609 bool WH3 = (Mouse->CursorPos.x >= ClientOrigin.x +
OutputLog3->Left) && (Mouse->CursorPos.x < (ClientOrigin.x +
OutputLog3->Width +
OutputLog3->Left))
8612 bool WH4 = (Mouse->CursorPos.x >= ClientOrigin.x +
OutputLog4->Left) && (Mouse->CursorPos.x < (ClientOrigin.x +
OutputLog4->Width +
OutputLog4->Left))
8615 bool WH5 = (Mouse->CursorPos.x >= ClientOrigin.x +
OutputLog5->Left) && (Mouse->CursorPos.x < (ClientOrigin.x +
OutputLog5->Width +
OutputLog5->Left))
8618 bool WH6 = (Mouse->CursorPos.x >= ClientOrigin.x +
OutputLog6->Left) && (Mouse->CursorPos.x < (ClientOrigin.x +
OutputLog6->Width +
OutputLog6->Left))
8621 bool WH7 = (Mouse->CursorPos.x >= ClientOrigin.x +
OutputLog7->Left) && (Mouse->CursorPos.x < (ClientOrigin.x +
OutputLog7->Width +
OutputLog7->Left))
8624 bool WH8 = (Mouse->CursorPos.x >= ClientOrigin.x +
OutputLog8->Left) && (Mouse->CursorPos.x < (ClientOrigin.x +
OutputLog8->Width +
OutputLog8->Left))
8627 bool WH9 = (Mouse->CursorPos.x >= ClientOrigin.x +
OutputLog9->Left) && (Mouse->CursorPos.x < (ClientOrigin.x +
OutputLog9->Width +
OutputLog9->Left))
8630 bool WH10 = (Mouse->CursorPos.x >= ClientOrigin.x +
OutputLog10->Left) &&
8634 if(WH1 || WH2 || WH3 || WH4 || WH5 || WH6 || WH7 || WH8 || WH9 || WH10)
8654 AnsiString Type[15] =
8656 "Simple",
"Crossover",
"Points",
"Buffers",
"Bridge",
"SignalPost",
"Continuation",
"Platform",
"GapJump",
"FootCrossing",
"Unused",
"Concourse",
8657 "Parapet",
"NamedNonStationLocation",
"Erase"
8660 int ScreenX = Mouse->CursorPos.x -
MainScreen->ClientOrigin.x;
8661 int ScreenY = Mouse->CursorPos.y -
MainScreen->ClientOrigin.y;
8663 AnsiString MouseStr =
"Posx: " + AnsiString(ScreenX) +
"; Posy: " + AnsiString(ScreenY);
8668 DevelopmentPanel->Caption = MouseStr +
"; TVPos: " + AnsiString(Position) +
"; H: " + AnsiString(HLoc) +
"; V: " + AnsiString(VLoc) +
8669 "; SpTg: " + AnsiString(TrackElement.
SpeedTag) +
"; Type: " + Type[TrackElement.
TrackType] +
"; Att: " + AnsiString(TrackElement.
Attribute)
8686 if((GetKeyState(VK_LBUTTON) >= 0) && (GetKeyState(VK_RBUTTON) >= 0) && (
TTCurrentEntryPtr > 0))
8816 Screen->Cursor = TCursor(-11);
9001 int RouteStartVecPos;
9017 if(FoundFlag && (RouteStartVecPos > -1))
9033 catch(
const Exception &e)
9051 InfoPanel->Caption =
"CALLING ON: Select signal for call on";
9065 catch(
const Exception &e)
9079 Screen->Cursor = TCursor(-11);
9123 Screen->Cursor = TCursor(-2);
9126 catch(
const Exception &e)
9140 Screen->Cursor = TCursor(-11);
9184 Screen->Cursor = TCursor(-2);
9187 catch(
const Exception &e)
9201 Screen->Cursor = TCursor(-11);
9246 Screen->Cursor = TCursor(-2);
9249 catch(
const Exception &e)
9263 Screen->Cursor = TCursor(-11);
9307 Screen->Cursor = TCursor(-2);
9310 catch(
const Exception &e)
9324 Screen->Cursor = TCursor(-11);
9365 OperateButton->Glyph->LoadFromResourceName(0,
"PauseGraphic");
9372 OperateButton->Glyph->LoadFromResourceName(0,
"RunGraphic");
9381 OperateButton->Glyph->LoadFromResourceName(0,
"RunGraphic");
9408 if((LeftExcess > 0) && (RightExcess > 0))
9412 else if((LeftExcess > 0) && (RightExcess <= 0))
9417 else if((LeftExcess <= 0) && (RightExcess > 0))
9429 if((TopExcess > 0) && (BotExcess > 0))
9433 else if((TopExcess > 0) && (BotExcess <= 0))
9438 else if((TopExcess <= 0) && (BotExcess > 0))
9454 ZoomButton->Glyph->LoadFromResourceName(0,
"ZoomIn");
9456 Screen->Cursor = TCursor(-2);
9460 catch(
const Exception &e)
9474 Screen->Cursor = TCursor(-11);
9499 Screen->Cursor = TCursor(-2);
9503 catch(
const Exception &e)
9531 catch(
const Exception &e)
9547 catch(
const Exception &e)
9568 ShowMessage(
"Please be aware when pasting that anything inside the pasted area will be overwritten.\n\nThis warning will not be shown again.");
9579 catch(
const Exception &e)
9601 TRect NewSelectRect(TLHCH, TLHCV, BRHCH, BRHCV);
9639 catch(
const Exception &e)
9660 catch(
const Exception &e)
9681 catch(
const Exception &e)
9719 int FlipLinkArray[10] =
9721 0, 7, 8, 9, 4, 5, 6, 1, 2, 3
9742 bool ELinkPosFound =
false, XLinkPosFound =
false;
9743 for(
int y = 0; y < 4; y++)
9745 if(!ELinkPosFound && (PDE.
Link[y] == ELink))
9748 ELinkPosFound =
true;
9750 if(!XLinkPosFound && (PDE.
Link[y] == XLink))
9753 XLinkPosFound =
true;
9762 bool FoundFlag =
false;
9769 if(!PDE.
EntryExitNumber() || !ELinkPosFound || !XLinkPosFound || !FoundFlag)
9772 ShowMessage(
"Unable to re-orientate the preferred directions, these won't be set in the rotated selection");
9791 int MidVPosAfterFlip = ((VerSum * 16) + 15) - MidVPosBeforeFlip;
9799 catch(
const Exception &e)
9837 int MirrorLinkArray[10] =
9839 0, 3, 2, 1, 6, 5, 4, 9, 8, 7
9860 bool ELinkPosFound =
false, XLinkPosFound =
false;
9861 for(
int y = 0; y < 4; y++)
9863 if(!ELinkPosFound && (PDE.
Link[y] == ELink))
9866 ELinkPosFound =
true;
9868 if(!XLinkPosFound && (PDE.
Link[y] == XLink))
9871 XLinkPosFound =
true;
9879 bool FoundFlag =
false;
9886 if(!PDE.
EntryExitNumber() || !ELinkPosFound || !XLinkPosFound || !FoundFlag)
9889 ShowMessage(
"Unable to re-orientate the preferred directions, these won't be set in the rotated selection");
9908 int MidHPosAfterMirror = ((HorSum * 16) + 15) - MidHPosBeforeMirror;
9910 if(LeftPosAfterMirror < (
SelectRect.left * 16))
9920 catch(
const Exception &e)
9962 int Rot180LinkArray[10] =
9964 0, 9, 8, 7, 6, 5, 4, 3, 2, 1
9984 bool ELinkPosFound =
false, XLinkPosFound =
false;
9985 for(
int y = 0; y < 4; y++)
9987 if(!ELinkPosFound && (PDE.
Link[y] == ELink))
9990 ELinkPosFound =
true;
9992 if(!XLinkPosFound && (PDE.
Link[y] == XLink))
9995 XLinkPosFound =
true;
10003 bool FoundFlag =
false;
10010 if(!PDE.
EntryExitNumber() || !ELinkPosFound || !XLinkPosFound || !FoundFlag)
10013 ShowMessage(
"Unable to re-orientate the preferred directions, these won't be set in the rotated selection");
10033 int MidVPosAfterFlip = ((VerSum * 16) + 15) - MidVPosBeforeFlip;
10045 int MidHPosAfterMirror = ((HorSum * 16) + 15) - MidHPosBeforeMirror;
10047 if(LeftPosAfterMirror < (
SelectRect.left * 16))
10059 catch(
const Exception &e)
10072 Screen->Cursor = TCursor(-11);
10089 int button = Application->MessageBox
10090 (L
"Original selection adjusted to make it square. 'OK' to keep this selection or 'Cancel' to make a new selection",
10091 L
"Left click and hold here to move this message box", MB_OKCANCEL);
10092 if(button == IDCANCEL)
10100 Screen->Cursor = TCursor(-2);
10140 if(IATVecPair.second != IATVecPair.first)
10150 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
10160 if(PrefDirPos0 > -1)
10165 if(PrefDirPos1 > -1)
10170 if(PrefDirPos2 > -1)
10175 if(PrefDirPos3 > -1)
10188 int HighSelectVPos =
SelectRect.bottom * 16;
10194 if((TextPtr->HPos >= LowSelectHPos) && (TextPtr->HPos < HighSelectHPos) && (TextPtr->VPos >= LowSelectVPos) && (TextPtr->VPos < HighSelectVPos))
10201 bool SelectVectorNamedElement =
false;
10202 AnsiString SelectTextString;
10207 SelectVectorNamedElement =
true;
10211 if(SelectVectorNamedElement)
10213 SelectTextString =
"##**" + TextPtr->TextString;
10217 SelectTextString = TextPtr->TextString;
10219 TTextItem TextItem(TextPtr->HPos, TextPtr->VPos, SelectTextString, TextPtr->Font);
10229 for(TTrack::TUserGraphicVector::iterator UserGraphicPtr =
Track->
UserGraphicVector.begin(); UserGraphicPtr < Track->UserGraphicVector.end();
10232 if((UserGraphicPtr->HPos >= LowSelectHPos) && ((UserGraphicPtr->HPos + UserGraphicPtr->Width) < HighSelectHPos) && (UserGraphicPtr->VPos >=
10233 LowSelectVPos) && ((UserGraphicPtr->VPos + UserGraphicPtr->Height) < HighSelectVPos))
10259 int RotRightLinkArray[10] =
10261 0, 3, 6, 9, 2, 5, 8, 1, 4, 7
10281 bool ELinkPosFound =
false, XLinkPosFound =
false;
10282 for(
int y = 0; y < 4; y++)
10284 if(!ELinkPosFound && (PDE.
Link[y] == ELink))
10287 ELinkPosFound =
true;
10289 if(!XLinkPosFound && (PDE.
Link[y] == XLink))
10292 XLinkPosFound =
true;
10300 bool FoundFlag =
false;
10307 if(!PDE.
EntryExitNumber() || !ELinkPosFound || !XLinkPosFound || !FoundFlag)
10310 ShowMessage(
"Unable to re-orientate the preferred directions, these won't be set in the rotated selection");
10332 int MidHPosAfterRotate = ((
SelectRect.bottom * 16) - 1) + (
SelectRect.left * 16) - MidVPosBeforeRotate;
10339 Screen->Cursor = TCursor(-2);
10344 catch(
const Exception &e)
10358 Screen->Cursor = TCursor(-11);
10375 int button = Application->MessageBox
10376 (L
"Original selection adjusted to make it square. 'OK' to keep this selection or 'Cancel' to make a new selection",
10377 L
"Left click and hold here to move this message box", MB_OKCANCEL);
10378 if(button == IDCANCEL)
10386 Screen->Cursor = TCursor(-2);
10426 if(IATVecPair.second != IATVecPair.first)
10436 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
10446 if(PrefDirPos0 > -1)
10451 if(PrefDirPos1 > -1)
10456 if(PrefDirPos2 > -1)
10461 if(PrefDirPos3 > -1)
10474 int HighSelectVPos =
SelectRect.bottom * 16;
10480 if((TextPtr->HPos >= LowSelectHPos) && (TextPtr->HPos < HighSelectHPos) && (TextPtr->VPos >= LowSelectVPos) && (TextPtr->VPos < HighSelectVPos))
10487 bool SelectVectorNamedElement =
false;
10488 AnsiString SelectTextString;
10493 SelectVectorNamedElement =
true;
10497 if(SelectVectorNamedElement)
10499 SelectTextString =
"##**" + TextPtr->TextString;
10503 SelectTextString = TextPtr->TextString;
10505 TTextItem TextItem(TextPtr->HPos, TextPtr->VPos, SelectTextString, TextPtr->Font);
10515 for(TTrack::TUserGraphicVector::iterator UserGraphicPtr =
Track->
UserGraphicVector.begin(); UserGraphicPtr < Track->UserGraphicVector.end();
10518 if((UserGraphicPtr->HPos >= LowSelectHPos) && ((UserGraphicPtr->HPos + UserGraphicPtr->Width) < HighSelectHPos) && (UserGraphicPtr->VPos >=
10519 LowSelectVPos) && ((UserGraphicPtr->VPos + UserGraphicPtr->Height) < HighSelectVPos))
10545 int RotLeftLinkArray[10] =
10547 0, 7, 4, 1, 8, 5, 2, 9, 6, 3
10567 bool ELinkPosFound =
false, XLinkPosFound =
false;
10568 for(
int y = 0; y < 4; y++)
10570 if(!ELinkPosFound && (PDE.
Link[y] == ELink))
10573 ELinkPosFound =
true;
10575 if(!XLinkPosFound && (PDE.
Link[y] == XLink))
10578 XLinkPosFound =
true;
10586 bool FoundFlag =
false;
10593 if(!PDE.
EntryExitNumber() || !ELinkPosFound || !XLinkPosFound || !FoundFlag)
10596 ShowMessage(
"Unable to re-orientate the preferred directions, these won't be set in the rotated selection");
10619 int MidVPosAfterRotate = ((
SelectRect.bottom * 16) - 1) + (
SelectRect.left * 16) - MidHPosBeforeRotate;
10625 Screen->Cursor = TCursor(-2);
10630 catch(
const Exception &e)
10650 catch(
const Exception &e)
10669 catch(
const Exception &e)
10687 InfoPanel->Caption =
"DISTANCE/SPEED SETTING: Set values or leave blank for no change";
10690 ShowMessage(
"Note: length value will apply to each element's track within the selection.\n\nThis message will not be shown again.");
10700 catch(
const Exception &e)
10718 bool FoundFlag =
false;
10762 catch(
const Exception &e)
10794 Clipboard()->Clear();
10795 Clipboard()->Close();
10798 catch(
const EClipboardException &e)
10804 catch(
const Exception &e)
10822 int PD0, PD1, PD2, PD3, HLoc, VLoc, LastHLoc = -2000000, LastVLoc = -2000000;
10823 AnsiString TempInfo =
InfoPanel->Caption;
10826 ShowMessage(
"No preferred directions set.");
10834 InfoPanel->Caption =
"Checking preferred directions - please wait";
10837 LastHVPair.first = -2000000;
10838 LastHVPair.second = -2000000;
10839 Screen->Cursor = TCursor(-11);
10842 bool BiDirLinkFound =
true;
10843 int LinkedPrefDirVectorNumber;
10844 THVPair CurrentHVPair = PDMMIt->first;
10845 if(CurrentHVPair != LastHVPair)
10849 if((PD0 > -1) && (PD1 > -1))
10858 BiDirLinkFound =
false;
10863 BiDirLinkFound =
false;
10867 if(BiDirLinkFound && (PD0 > -1) && (PD2 > -1))
10875 BiDirLinkFound =
false;
10880 BiDirLinkFound =
false;
10884 if(BiDirLinkFound && (PD0 > -1) && (PD3 > -1))
10892 BiDirLinkFound =
false;
10897 BiDirLinkFound =
false;
10901 if(BiDirLinkFound && (PD1 > -1) && (PD2 > -1))
10909 BiDirLinkFound =
false;
10914 BiDirLinkFound =
false;
10918 if(BiDirLinkFound && (PD1 > -1) && (PD3 > -1))
10926 BiDirLinkFound =
false;
10931 BiDirLinkFound =
false;
10935 if(BiDirLinkFound && (PD2 > -1) && (PD3 > -1))
10943 BiDirLinkFound =
false;
10948 BiDirLinkFound =
false;
10952 if(!BiDirLinkFound)
10956 if((LastHLoc != HLoc) || (LastVLoc != VLoc))
10978 Screen->Cursor = TCursor(-2);
10979 int Button = Application->MessageBox(L
"Possible mismatch in preferred direction links \n"
10980 "at the position shown - see inverted element (may \n"
10981 "be behind this message). \n\n"
10982 "Click 'OK' to ignore and continue checking or \n"
10983 "'Cancel' to allow correction.", L
"Warning", MB_OKCANCEL | MB_ICONWARNING);
10985 if(Button == IDCANCEL)
10991 Screen->Cursor = TCursor(-11);
10996 LastHVPair = CurrentHVPair;
10998 bool ELinkFound =
false, BiDir =
false;
11066 if((LastHLoc != HLoc) || (LastVLoc != VLoc))
11088 Screen->Cursor = TCursor(-2);
11089 int Button = Application->MessageBox(L
"Possible mismatch in preferred direction links \n"
11090 "at the position shown - see inverted element (may \n"
11091 "be behind this message). \n\n"
11092 "Click 'OK' to ignore and continue checking or \n"
11093 "'Cancel' to allow correction.", L
"Warning", MB_OKCANCEL | MB_ICONWARNING);
11095 if(Button == IDCANCEL)
11101 Screen->Cursor = TCursor(-11);
11106 bool XLinkFound =
false;
11175 if((LastHLoc != HLoc) || (LastVLoc != VLoc))
11197 Screen->Cursor = TCursor(-2);
11198 int Button = Application->MessageBox(L
"Possible mismatch in preferred direction links \n"
11199 "at the position shown - see inverted element (may \n"
11200 "be behind this message). \n\n"
11201 "Click 'OK' to ignore and continue checking or \n"
11202 "'Cancel' to allow correction.", L
"Warning", MB_OKCANCEL | MB_ICONWARNING);
11204 if(Button == IDCANCEL)
11210 Screen->Cursor = TCursor(-11);
11216 Screen->Cursor = TCursor(-2);
11217 ShowMessage(
"Finished");
11221 catch(
const Exception &e)
11223 Screen->Cursor = TCursor(-2);
11224 ShowMessage(
"Error in preferred direction checking, unable to complete the check");
11256 bool CheckLocationsExistInRailwayTrue =
true;
11260 Screen->Cursor = TCursor(-11);
11261 std::ifstream TTBLFile(AnsiString(
TimetableDialog->FileName).c_str(), std::ios_base::binary);
11262 if(TTBLFile.is_open())
11264 bool SessionFileFalse =
false;
11273 ShowMessage(
"Failed to open timetable file, make sure it's spelled correctly, it exists and isn't open in another application");
11275 Screen->Cursor = TCursor(-2);
11279 ShowMessage(
"Timetable integrity check failed - unable to load " +
TimetableDialog->FileName +
". Please check that the file exists and is spelled correctly.");
11286 catch(
const Exception &e)
11313 AnsiString LocName =
"";
11318 if((LocName ==
"") && (Train.
MidElement > -1))
11336 if((NextElementPosition > -1) && (NextEntryPos > -1))
11352 if((LocName ==
"") && (Train.
MidElement > -1))
11359 catch(
const Exception &e)
11393 if((LeadElementLocName ==
"") && (MidElementLocName ==
"") && (Train.
LeadElement > -1))
11397 if((LeadElementLocName ==
"") && (Train.
MidElement > -1))
11401 if((LeadElementLocName == RequiredLocName) || (MidElementLocName == RequiredLocName))
11403 LocName = RequiredLocName;
11435 int NextElementPos = -1;
11436 int NextEntryPos = -1;
11455 if((NextElementPos > -1) && (NextEntryPos > -1))
11489 catch(
const Exception &e)
11507 AnsiString LocName =
"";
11512 if((LocName ==
"") && (Train.
MidElement > -1))
11520 if((LocName ==
"") && (Train.
MidElement > -1))
11527 catch(
const Exception &e)
11557 int NextElementPos = -1;
11558 int NextEntryPos = -1;
11566 if((NextElementPos > -1) && (NextEntryPos > -1))
11586 catch(
const Exception &e)
11600 TTrain *TrainToBeJoinedBy;
11613 ShowMessage(
"Can't join two trains when both are without power");
11617 AnsiString TrainToBeJoinedByHeadCode = TrainToBeJoinedBy->
HeadCode;
11619 double OtherBrakeForce = TrainToBeJoinedBy->
MaxBrakeRate * TrainToBeJoinedBy->
Mass;
11621 double CombinedBrakeRate = (OtherBrakeForce + OwnBrakeForce) / (TrainToBeJoinedBy->
Mass + ThisTrain.
Mass);
11622 ThisTrain.
Mass += TrainToBeJoinedBy->
Mass;
11629 AnsiString LocName =
"";
11634 if((LocName ==
"") && (ThisTrain.
MidElement > -1))
11638 if((LocName ==
"") && ThisTrain.
LeadElement > -1)
11642 if((LocName ==
"") && (ThisTrain.
MidElement > -1))
11676 catch(
const Exception &e)
11707 AnsiString LocName =
"";
11712 if((LocName ==
"") && (Train.
MidElement > -1))
11720 if((LocName ==
"") && (Train.
MidElement > -1))
11736 catch(
const Exception &e)
11771 catch(
const Exception &e)
11787 if(NextElementPos < 0)
11789 throw Exception(
"Error, no element in front in PassRedSignalMenuItemClick");
11800 throw Exception(
"Error, next element not a signal type in PassRedSignalMenuItemClick");
11814 catch(
const Exception &e)
11840 int NextElementPos = -1;
11842 int NextEntryPos = -1;
11850 if((NextElementPos > -1) && (NextEntryPos > -1))
11860 catch(
const Exception &e)
11879 UnicodeString Message = UnicodeString(Train.
HeadCode) +
" will be removed from the railway - proceed?";
11880 int button = Application->MessageBox(Message.c_str(), L
"Please confirm", MB_YESNO);
11893 AnsiString LocName =
"";
11898 if((LocName ==
"") && (Train.
MidElement > -1))
11906 if((LocName ==
"") && (Train.
MidElement > -1))
11953 int FirstRouteElementVecPos = LeadTrackElement.
Conn[Train.
LeadExitPos];
11963 bool FirstPass =
true;
11970 if(FirstPass && (TVPos2 != FirstRouteElementVecPos))
12049 catch(
const Exception &e)
12064 Application->Terminate();
12078 catch(
const Exception &e)
12106 UnicodeString MessStr =
"";
12109 MessStr = UnicodeString(
"The railway and the timetable have both changed, exit without saving either?");
12113 MessStr = UnicodeString(
"The railway has changed, exit without saving?");
12117 MessStr = UnicodeString(
"The timetable has changed, exit without saving?");
12119 int button = Application->MessageBox(MessStr.c_str(), L
"Please confirm", MB_YESNO);
12131 UnicodeString MessageStr =
"Please note that the session will be lost if it hasn't been saved. Do you still wish to exit?";
12134 int button = Application->MessageBox(MessageStr.c_str(), L
"Please confirm", MB_YESNO);
12153 catch(
const Exception &e)
12167 if((Shift.Contains(ssAlt)) && (Shift.Contains(ssCtrl)))
12180 else if(Key ==
'3')
12192 else if(Key ==
'4')
12196 else if(Key ==
'5')
12198 TMsgDlgButtons Buttons;
12199 Buttons << mbYes << mbNo;
12200 if(MessageDlg(
"Do you wish to allow facing signals next to bridges? If so please be aware that routes cannot be truncated to these signals.",
12201 mtWarning, Buttons, 0) == mrYes)
12211 else if(Shift.Contains(ssCtrl) && !Shift.Contains(ssShift) && !Shift.Contains(ssAlt))
12215 else if(Shift.Contains(ssShift) && !Shift.Contains(ssCtrl) && !Shift.Contains(ssAlt))
12227 if((Key != VK_SHIFT) && (Key != VK_CONTROL))
12245 else if(Key == VK_DOWN)
12252 else if(Key == VK_LEFT)
12259 else if(Key == VK_RIGHT)
12266 else if(Key == VK_HOME)
12274 else if(Key == VK_END)
12281 else if(Key == VK_END)
12296 if(Shift.Contains(ssShift) && !Shift.Contains(ssAlt) && !Shift.Contains(ssCtrl) &&
NewHomeButton->Enabled &&
NewHomeButton->Visible)
12307 if(!Shift.Contains(ssCtrl))
12371 if(Key ==
'S' || Key ==
's')
12382 if(Shift.Contains(ssShift))
12397 if(Shift.Contains(ssShift) && !Shift.Contains(ssCtrl) && !Shift.Contains(ssAlt))
12444 if(Shift.Contains(ssCtrl) && !Shift.Contains(ssShift) && !Shift.Contains(ssAlt))
12450 if(Key ==
'S' || Key ==
's')
12456 if(!Shift.Contains(ssCtrl) && !Shift.Contains(ssShift) && !Shift.Contains(ssAlt))
12467 if(!Shift.Contains(ssShift) && !Shift.Contains(ssCtrl))
12474 if(!Shift.Contains(ssShift) && Shift.Contains(ssCtrl))
12480 if(Key ==
'S' || Key ==
's')
12486 if(Shift.Contains(ssShift) && !Shift.Contains(ssCtrl))
12507 if(!Shift.Contains(ssShift) && !Shift.Contains(ssCtrl))
12514 if(Shift.Contains(ssShift) && !Shift.Contains(ssCtrl))
12520 if(Key ==
'S' || Key ==
's')
12525 else if(Key ==
'H' || Key ==
'h')
12538 if(Shift.Contains(ssShift) && !Shift.Contains(ssCtrl))
12609 if(
SaveTTButton->Enabled && (Key ==
'T' || Key ==
't'))
12632 if(
FloatingInfoMenu->Enabled && !Shift.Contains(ssAlt) && Shift.Contains(ssCtrl) && Shift.Contains(ssShift))
12634 if(Key ==
'I' || Key ==
'i')
12640 if(Key ==
'S' || Key ==
's')
12644 else if(Key ==
'T' || Key ==
't')
12653 catch(
const Exception &e)
12663 if((Key != VK_SHIFT) && (Key != VK_CONTROL))
12785 catch(
const Exception &e)
12798 Application->HelpKeyword(u
"Introduction");
12800 catch(
const Exception &e)
12810 const UnicodeString Link =
"http://www.railwayoperationsimulator.com";
12811 ::ShellExecute(Handle, NULL, (Link).c_str(), NULL, NULL, SW_SHOWNORMAL);
12834 catch(
const Exception &e)
12860 catch(
const Exception &e)
12886 catch(
const Exception &e)
12942 bool ErrorFlag =
false, TooBigFlag =
false;
12963 if(!ErrorFlag && !TooBigFlag)
12973 int KPH = (MPH * 1.609344) + 0.5;
12980 int MPH = (KPH * 0.621371) + 0.5;
12991 catch(
const EConvertError &ec)
12996 catch(
const Exception &e)
13031 bool ErrorFlag =
false, TooBigFlag =
false;
13052 if(!ErrorFlag && !TooBigFlag)
13062 int KW = (HP * 0.745699872) + 0.5;
13069 int HP = (KW * 1.340482574) + 0.5;
13080 catch(
const EConvertError &ec)
13085 catch(
const Exception &e)
13098 bool ErrorFlag =
false, TooBigFlag =
false;
13119 if(!ErrorFlag && !TooBigFlag)
13129 int KPH = (MPH * 1.609344) + 0.5;
13136 int MPH = (KPH * 0.621371) + 0.5;
13147 catch(
const EConvertError &ec)
13152 catch(
const Exception &e)
13166 bool ErrorFlag =
false, TooLongFlag =
false;
13169 for(
int x = 1; x <=
MileEdit->Text.Length(); x++)
13181 for(
int x = 1; x <=
ChainEdit->Text.Length(); x++)
13193 for(
int x = 1; x <=
YardEdit->Text.Length(); x++)
13205 TooLongFlag =
true;
13208 if(!ErrorFlag && !TooLongFlag)
13210 int Miles = 0, Chains = 0, Yards = 0, Metres = 0;
13223 Metres = int((Miles * 1609.344) + (Chains * 20.1168) + (Yards * 0.9144) + 0.5);
13232 catch(
const EConvertError &ec)
13237 catch(
const Exception &e)
13268 catch(
const Exception &e)
13305 "Changes have been made to the timetable clock - you may wish to save a session before resuming operation.\n\nTo cancel all changes re-click the 'Adjust the timetable clock' button then click the reset button BEFORE resuming operation.";
13314 catch(
const Exception &e)
13332 catch(
const Exception &e)
13351 catch(
const Exception &e)
13370 catch(
const Exception &e)
13389 catch(
const Exception &e)
13408 catch(
const Exception &e)
13427 catch(
const Exception &e)
13446 catch(
const Exception &e)
13466 catch(
const Exception &e)
13485 catch(
const Exception &e)
13499 double TTClockIncrement = 1.0 / 24;
13505 catch(
const Exception &e)
13519 double TTClockIncrement = 1.0 / 144;
13525 catch(
const Exception &e)
13539 double TTClockIncrement = 1.0 / 1440;
13545 catch(
const Exception &e)
13602 catch(
const Exception &e)
13616 InfoPanel->Caption =
"PRE-START: Presetting automatic signal routes";
13627 Screen->Cursor = TCursor(-11);
13629 bool PointsChanged, AtLeastOneSet =
false;
13630 int LastIteratorValue = 0;
13639 AtLeastOneSet =
true;
13656 ShowMessage(
"No presettable automatic signal routes are available");
13658 Screen->Cursor = TCursor(-2);
13661 catch(
const Exception &e)
13676 int DispW = (
Interface->Width - 64 - 16) / 16;
13678 int DispH = (
Interface->Height - 192) / 16;
13710 catch(
const Exception &e)
13740 catch(
const Exception &e)
13766 SigImagePanel->Caption =
"Signals will be on the right hand side of the track";
13771 std::ofstream SigFile((
CurDir +
"\\Signal.hnd").c_str());
13774 ShowMessage(
"Failed to store right hand signal setting, program will default to left hand signals when next loaded");
13792 SigImagePanel->Caption =
"Signals will be on the left hand side of the track";
13797 std::ofstream SigFile((
CurDir +
"\\Signal.hnd").c_str());
13809 catch(
const Exception &e)
13828 bool TooBigFlag =
false, BadCharsFlag =
false;
13833 for(
int x = 1; x <=
MTBFEditBox->Text.Length(); x++)
13837 BadCharsFlag =
true;
13850 ShowMessage(
"Maximum value allowed is 9,999");
13859 ShowMessage(
"Value must be a whole number with no special characters");
13876 catch(
const Exception &e)
13894 "Values can only be entered or changed in Pre-Start mode\ni.e. after selecting 'Operate railway' but before clicking 'Run'");
13898 catch(
const Exception &e)
13931 catch(
const Exception &e)
13957 catch(
const Exception &e)
13973 catch(
const Exception &e)
13994 catch(
const Exception &e)
14018 catch(
const Exception &e)
14035 catch(
const Exception &e)
14052 catch(
const Exception &e)
14068 ShowMessage(
"No boxes ticked!");
14072 Screen->Cursor = TCursor(-11);
14073 AnsiString TTTitle;
14087 ShowMessage(
"Analysis complete and file created");
14092 Screen->Cursor = TCursor(-2);
14095 catch(
const Exception &e)
14137 int WidthNum = int(
MainScreen->Width / 160) + 1;
14138 int HeightNum = int(
MainScreen->Height / 144) + 1;
14139 for(
int x = 0; x < WidthNum; x++)
14141 for(
int y = 0; y < HeightNum; y++)
14246 bool BreakFlag =
false;
14355 ZoomButton->Glyph->LoadFromResourceName(0,
"ZoomOut");
14389 InfoPanel->Caption =
"CONNECTING GAPS: Click on connecting element";
14405 UnicodeString MessageStr =
"The railway has changed, close it without saving?";
14406 int button = Application->MessageBox(MessageStr.c_str(), L
"Please confirm", MB_YESNO);
14455 std::ifstream VecFile(FileName);
14457 if(VecFile.is_open())
14477 bool GraphicsFollow =
false;
14478 int NumberOfActiveElements;
14491 if(!(EveryPrefDir->CheckOnePrefDir(0, NumberOfActiveElements, VecFile)))
14522 TDateTime First, Second;
14523 bool Finished =
false;
14525 First = TDateTime::CurrentDateTime();
14526 double TimeVal1 = 86400000 * double(First);
14530 Second = TDateTime::CurrentDateTime();
14531 double TimeVal2 = 86400000 * double(Second);
14532 if((TimeVal2 - TimeVal1) > Msec)
14592 if((LinkNumber1 == 1) || (LinkNumber1 == 3) || (LinkNumber1 == 7) || (LinkNumber1 == 9))
14600 if((LinkNumber2 == 1) || (LinkNumber2 == 3) || (LinkNumber2 == 7) || (LinkNumber2 == 9))
14752 InfoPanel->Caption =
"Select an option from the File, Mode or Help menus";
14911 Screen->Cursor = TCursor(-11);
14919 InfoPanel->Caption =
"PREFERRED DIRECTION SETTING: Select preferred direction start location (right click to erase)";
14944 Screen->Cursor = TCursor(-2);
14993 MTBFLabel->Caption =
"Mean time between\ntrain failures in\ntimetable hours";
15006 OperateButton->Glyph->LoadFromResourceName(0,
"RunGraphic");
15033 ShowMessage(
"Performance logfile failed to open, logs won't be saved. Ensure that there is a folder named " +
PERFLOG_DIR_NAME +
15034 " in the folder where the 'Railway.exe' program file resides");
15082 OAListBox->Items->Add(L
"locate train");
15086 OAListBox->Items->Add(L
"headcode for");
15090 OAListBox->Items->Add(L
"Left click and");
15091 OAListBox->Items->Add(L
"hold grey area");
15092 OAListBox->Items->Add(L
"to move panel");
15126 OperateButton->Glyph->LoadFromResourceName(0,
"RunGraphic");
15151 OAListBox->Items->Add(L
"locate train");
15155 OAListBox->Items->Add(L
"headcode for");
15159 OAListBox->Items->Add(L
"Left click and");
15160 OAListBox->Items->Add(L
"hold grey area");
15161 OAListBox->Items->Add(L
"to move panel");
15175 MTBFLabel->Caption =
"Mean time between\ntrain failures in\ntimetable hours";
15184 MTBFLabel->Caption =
"Mean time between\ntrain failures in\ntimetable hours";
15225 InfoPanel->Caption =
"ADDING TRACK: Select element then left click to add it. Right click an element to remove it.";
15264 InfoPanel->Caption =
"ADDING GRAPHIC: Left click layout to add SELECTED graphic, right click to remove ANY graphic.";
15269 InfoPanel->Caption =
"SELECTING USER GRAPHIC: Select the graphic file then add as many as necessary to the layout.";
15273 int HLoc, VLoc, Count;
15275 if(div(Count, 2).rem == 1)
15277 ShowMessage(
"Can't connect, there are an odd number of gaps");
15292 ShowMessage(
"Error - Even number of gaps but all set after first call to HighLightOneGap");
15302 InfoPanel->Caption =
"CONNECTING GAPS: Click on connecting gap";
15309 InfoPanel->Caption =
"ADDING/EDITING TEXT: Left click to add, right click first letter to erase, or left click first letter to edit)";
15324 InfoPanel->Caption =
"MOVING TEXT OR GRAPHIC: If text left click first letter, if graphic left click anywhere, then drag";
15331 InfoPanel->Caption =
"NAMING LOCATIONS: Click on location element to add or change name";
15339 InfoPanel->Caption =
"DISTANCE/SPEED SETTING: Select first location (only non-default elements marked)";
15351 InfoPanel->Caption =
"DISTANCE/SPEED SETTING: Select next location";
15355 InfoPanel->Caption =
"DISTANCE/SPEED SETTING: Continue or set values (overall length), or right click to cancel/truncate";
15370 InfoPanel->Caption =
"SELECTING: Select area - click left mouse && drag";
15380 InfoPanel->Caption =
"COPYING: Left click in selection && drag";
15406 bool EraseSuccessfulFlag, NeedToLink =
false, TextChangesMade =
false, GraphicChangesMade =
false;
15407 int ErasedTrackVectorPosition;
15408 Screen->Cursor = TCursor(-11);
15410 InfoPanel->Caption =
"CUT PROCESSING: Please do not click the mouse";
15417 if(EraseSuccessfulFlag)
15419 if(ErasedTrackVectorPosition > -1)
15432 int HighSelectVPos =
SelectRect.bottom * 16;
15438 if((TextPtr->HPos >= LowSelectHPos) && (TextPtr->HPos < HighSelectHPos) && (TextPtr->VPos >= LowSelectVPos) && (TextPtr->VPos <
15446 TextChangesMade =
true;
15456 if((GraphicPtr->HPos >= LowSelectHPos) && ((GraphicPtr->HPos + GraphicPtr->Width) < HighSelectHPos) && (GraphicPtr->VPos >= LowSelectVPos)
15457 && ((GraphicPtr->VPos + GraphicPtr->Height) < HighSelectVPos))
15460 GraphicChangesMade =
true;
15467 Screen->Cursor = TCursor(-2);
15474 InfoPanel->Caption =
"CUTTING: Left click in selection && drag";
15491 if(NeedToLink || TextChangesMade || GraphicChangesMade)
15519 UnicodeString MessageStr =
15520 "Please be aware of the relevant conditions when pasting " "a railway segment from a different application.\n"
15521 "These are set out in section 3.5 of the manual and " "on-screen help under the heading 'Pasting in an application "
15522 "after cutting or copying from a different application'.\n\n" "This warning will not be shown again.\n\n" "Proceed?";
15523 int button = Application->MessageBox(MessageStr.c_str(), L
"Warning", MB_YESNO | MB_ICONWARNING);
15535 Application->MessageBoxW(L
"Unable to paste (clipboard is invalid) - possibly because another application has changed it)", L
"Warning", MB_OK | MB_ICONWARNING);
15537 TrainController->
LogEvent(
"ValidResult false in case Pasting - probably due to error in RecoverClipboard - see earlier log");
15549 Clipboard()->Clear();
15550 Clipboard()->Close();
15553 bool NeedToLink =
false;
15554 bool TrackLinkingRequiredFlag;
15555 Screen->Cursor = TCursor(-11);
15557 InfoPanel->Caption =
"PASTING: Please wait";
15564 bool TrackEraseSuccessfulFlag;
15565 int ErasedTrackVectorPosition;
15567 for(
int x = LowSelectHLoc; x < HighSelectHLoc; x++)
15569 for(
int y = LowSelectVLoc; y < HighSelectVLoc; y++)
15572 if(ErasedTrackVectorPosition > -1)
15589 if((TextPtr->HPos >= LowSelectHPos) && (TextPtr->HPos < HighSelectHPos) && (TextPtr->VPos >= LowSelectVPos) && (TextPtr->VPos <
15606 if((GraphicPtr->HPos >= LowSelectHPos) && ((GraphicPtr->HPos + GraphicPtr->Width) < HighSelectHPos) && (GraphicPtr->VPos >= LowSelectVPos)
15607 && ((GraphicPtr->VPos + GraphicPtr->Height) < HighSelectVPos))
15621 AnsiString LocName;
15640 int HPos = 0, VPos = 0;
15653 bool InternalChecks =
false;
15657 TrackLinkingRequiredFlag, InternalChecks);
15673 if(TrackLinkingRequiredFlag)
15688 PDVIt->HLoc += HDiff;
15689 PDVIt->VLoc += VDiff;
15694 throw Exception(
"Failed to find TrackVectorPosition in PrefDir setting for Paste");
15696 PDVIt->SetTrackVectorPosition(ATVecPos);
15699 for(
int x = 0; x < 4; x++)
15701 PDVIt->Conn[x] = -1;
15702 PDVIt->ConnLinkPos[x] = -1;
15714 TextPtr->HPos += HDiff * 16;
15715 TextPtr->VPos += VDiff * 16;
15716 AnsiString TempString = TextPtr->TextString;
15732 if(TextPtr->TextString.SubString(1, 4) ==
"##**")
15734 TempString = TextPtr->TextString.SubString(5, TextPtr->TextString.Length());
15737 TextPtr->TextString =
"";
15750 for(TTrack::TUserGraphicVector::iterator GraphicPtr =
Track->
SelectGraphicVector.begin(); GraphicPtr < Track->SelectGraphicVector.end();
15753 GraphicPtr->HPos += HDiff * 16;
15754 GraphicPtr->VPos += VDiff * 16;
15769 Screen->Cursor = TCursor(-2);
15789 UnicodeString MessageStr =
"Selected area will be deleted - proceed?";
15790 int button = Application->MessageBox(MessageStr.c_str(), L
"Please confirm", MB_YESNO);
15795 bool EraseSuccessfulFlag, NeedToLink =
false, TextChangesMade =
false, GraphicChangesMade =
false;
15796 int ErasedTrackVectorPosition;
15797 Screen->Cursor = TCursor(-11);
15799 InfoPanel->Caption =
"DELETING: Please wait";
15806 if(EraseSuccessfulFlag)
15808 if(ErasedTrackVectorPosition > -1)
15820 int HighSelectVPos =
SelectRect.bottom * 16;
15826 AnsiString Check = TextPtr->TextString;
15827 if((TextPtr->HPos >= LowSelectHPos) && (TextPtr->HPos < HighSelectHPos) && (TextPtr->VPos >= LowSelectVPos) && (TextPtr->VPos <
15835 TextChangesMade =
true;
15854 if((GraphicPtr->HPos >= LowSelectHPos) && ((GraphicPtr->HPos + GraphicPtr->Width) < HighSelectHPos) && (GraphicPtr->VPos >= LowSelectVPos)
15855 && ((GraphicPtr->VPos + GraphicPtr->Height) < HighSelectVPos))
15860 if((UserGraphicPtr->HPos == GraphicPtr->HPos) && (UserGraphicPtr->VPos == GraphicPtr->VPos) &&
15861 (UserGraphicPtr->Width == GraphicPtr->Width) && (UserGraphicPtr->Height == GraphicPtr->Height) &&
15862 (UserGraphicPtr->FileName == GraphicPtr->FileName))
15865 GraphicChangesMade =
true;
15885 if(NeedToLink || TextChangesMade || GraphicChangesMade)
15889 Screen->Cursor = TCursor(-2);
15909 catch (
const EClipboardException &e)
15946 bool LeadingPointsAtLastElement =
false;
15949 if(LeadingPointsAtLastElement)
15951 InfoPanel->Caption =
"PREFERRED DIRECTION SETTING: Can't end on leading points, select next location or truncate";
15956 InfoPanel->Caption =
"PREFERRED DIRECTION SETTING: Select next preferred direction location (right click to truncate)";
15961 InfoPanel->Caption =
"PREFERRED DIRECTION SETTING: Add selection or select next location (right click to truncate)";
15976 InfoPanel->Caption =
"SELECTING: Select area - click left mouse && drag";
16017 OperateButton->Glyph->LoadFromResourceName(0,
"PauseGraphic");
16091 Display->
PerformanceLog(15, TimeMessage +
"Timetable clock speed changed to one sixteenth normal");
16099 if(TTClockTimeChange > 0.000347)
16102 int MinsIncrease = ((TTClockTimeChange * 1440) + 0.5);
16103 int HoursIncrease = 0;
16104 while(MinsIncrease >= 60)
16107 MinsIncrease -= 60;
16109 if(HoursIncrease == 0)
16111 TimeMessage +=
"Timetable clock incremented by " + AnsiString(MinsIncrease) +
"m";
16113 else if(MinsIncrease == 0)
16115 TimeMessage +=
"Timetable clock incremented by " + AnsiString(HoursIncrease) +
"h";
16119 TimeMessage +=
"Timetable clock incremented by " + AnsiString(HoursIncrease) +
"h " + AnsiString(MinsIncrease) +
"m";
16131 MTBFLabel->Caption =
"Mean time between\ntrain failures in\ntimetable hours";
16139 MTBFLabel->Caption =
"Mean time between\ntrain failures in\ntimetable hours";
16148 OperateButton->Glyph->LoadFromResourceName(0,
"RunGraphic");
16178 float LockDelay = 120.0;
16184 bool BreakFlag =
false;
16188 if((TTClockTime - LRVIT->LockStartTime) > TDateTime(LockDelay / 86400))
16191 AnsiString(LRVIT->LastTrackVectorPosition));
16192 while(Route.
LastElementPtr(9)->GetTrackVectorPosition() != LRVIT->TruncateTrackVectorPosition)
16209 if(Route.
LastElementPtr(17)->GetTrackVectorPosition() == LRVIT->TruncateTrackVectorPosition)
16250 int TempLockedVectorNumber;
16260 if(((TTClockTime - AutoSigVectorIT->PassoutTime) > TDateTime(AutoSigVectorIT->FirstDelay / 86400)) && (AutoSigVectorIT->AccessNumber == 0))
16263 AutoSigVectorIT->AccessNumber++;
16266 if(((TTClockTime - AutoSigVectorIT->PassoutTime) > TDateTime(AutoSigVectorIT->SecondDelay / 86400)) && (AutoSigVectorIT->AccessNumber == 1))
16269 AutoSigVectorIT->AccessNumber++;
16272 if(((TTClockTime - AutoSigVectorIT->PassoutTime) > TDateTime(AutoSigVectorIT->ThirdDelay / 86400)) && (AutoSigVectorIT->AccessNumber == 2))
16275 AutoSigVectorIT->AccessNumber++;
16283 if(AutoSigVectorIT->AccessNumber > 2)
16297 TPoint MousePoint = Mouse->CursorPos;
16298 int ScreenX = MousePoint.x -
MainScreen->ClientOrigin.x;
16299 int ScreenY = MousePoint.y -
MainScreen->ClientOrigin.y;
16311 ((MousePoint.y - ClientOrigin.y) >=
PerformancePanel->Top) && ((MousePoint.y - ClientOrigin.y) <=
16323 ((MousePoint.y - ClientOrigin.y) >=
TimetableEditPanel->Top) && ((MousePoint.y - ClientOrigin.y) <=
16332 AnsiString TrackFloat =
"", TrainStatusFloat =
"", TrainTTFloat =
"";
16333 bool ShowTrackFloatFlag =
false, ShowTrainStatusFloatFlag =
false, ShowTrainTTFloatFlag =
false;
16343 bool MouseOverOAPanel =
false;
16348 ((MousePoint.y - ClientOrigin.y) >=
OperatorActionPanel->Top) && ((MousePoint.y - ClientOrigin.y) <=
16351 MouseOverOAPanel =
true;
16357 bool ActiveTrackFoundFlag =
false, InactiveTrackFoundFlag =
false, TwoTrack =
false;
16358 AnsiString Length01Str =
"", Length23Str =
"", SpeedLimit01Str =
"", SpeedLimit23Str =
"";
16359 AnsiString StationEntryStopLinkPos1Str =
"", StationEntryStopLinkPos2Str =
"";
16360 AnsiString ATrackSN =
"", ATrackTN =
"", IATrackSN =
"", LengthAndSpeedCaption =
"";
16361 AnsiString SigAspectString =
"";
16365 if(InactiveTrackFoundFlag)
16370 if(ActiveTrackFoundFlag)
16377 if((ATrackTN !=
"") && (!InactiveTrackFoundFlag || ((InactiveTrackElement.
TrackType !=
Platform) &&
16381 ShowMessage(
"Error - Track has timetable name without corresponding plat/named loc");
16386 ShowMessage(
"Error - plat/named loc and track have different names, or plat/named loc named but not track");
16392 Length01Str = AnsiString(ActiveTrackElement.
Length01);
16393 if(Length01Str ==
"-1")
16395 Length01Str =
"Not Set";
16397 SpeedLimit01Str = AnsiString(ActiveTrackElement.
SpeedLimit01);
16398 if(SpeedLimit01Str ==
"-1")
16400 SpeedLimit01Str =
"Not Set";
16404 Length23Str = AnsiString(ActiveTrackElement.
Length23);
16405 if(Length23Str ==
"-1")
16407 Length23Str =
"Not Set";
16409 SpeedLimit23Str = AnsiString(ActiveTrackElement.
SpeedLimit23);
16410 if(SpeedLimit23Str ==
"-1")
16412 SpeedLimit23Str =
"Not Set";
16416 LengthAndSpeedCaption =
"Straight track length = " + Length01Str +
" m" +
'\n' +
"Diverging track length = " + Length23Str +
" m" +
'\n' +
16417 "Straight track speed limit = " + SpeedLimit01Str +
" km/h" +
'\n' +
"Diverging track speed limit = " + SpeedLimit23Str +
" km/h";
16421 LengthAndSpeedCaption =
"Left diverging track length = " + Length01Str +
" m" +
'\n' +
"Right diverging track length = " + Length23Str +
16422 " m" +
'\n' +
"Left diverging track speed limit = " + SpeedLimit01Str +
" km/h" +
'\n' +
"Right diverging track Speed Limit = " +
16423 SpeedLimit23Str +
" km/h";
16428 if((ActiveTrackElement.
SpeedTag == 15) || (ActiveTrackElement.
SpeedTag == 46))
16430 LengthAndSpeedCaption =
"Horizontal track length = " + Length01Str +
" m" +
'\n' +
"Other track length = " + Length23Str +
" m" +
'\n' +
16431 "Horizontal track speed limit = " + SpeedLimit01Str +
" km/h" +
'\n' +
"Other track speed limit = " + SpeedLimit23Str +
" km/h";
16433 else if(ActiveTrackElement.
SpeedTag == 47)
16435 LengthAndSpeedCaption =
"Horizontal track length = " + Length23Str +
" m" +
'\n' +
"Other track length = " + Length01Str +
" m" +
'\n' +
16436 "Horizontal track speed limit = " + SpeedLimit23Str +
" km/h" +
'\n' +
"Other track speed limit = " + SpeedLimit01Str +
" km/h";
16438 else if(ActiveTrackElement.
SpeedTag == 45)
16440 LengthAndSpeedCaption =
"Vertical track length = " + Length01Str +
" m" +
'\n' +
"Other track length = " + Length23Str +
" m" +
'\n' +
16441 "Vertical track speed limit = " + SpeedLimit01Str +
" km/h" +
'\n' +
"Other track speed limit = " + SpeedLimit23Str +
" km/h";
16443 else if(ActiveTrackElement.
SpeedTag == 44)
16445 LengthAndSpeedCaption =
"Vertical track length = " + Length23Str +
" m" +
'\n' +
"Other track length = " + Length01Str +
" m" +
'\n' +
16446 "Vertical track speed limit = " + SpeedLimit23Str +
" km/h" +
'\n' +
"Other track speed limit = " + SpeedLimit01Str +
" km/h";
16448 else if(ActiveTrackElement.
SpeedTag == 16)
16450 LengthAndSpeedCaption =
"Top left to bottom right track length = " + Length01Str +
" m" +
'\n' +
"Other track length = " + Length23Str +
16451 " m" +
'\n' +
"Top left to bottom right track speed limit = " + SpeedLimit01Str +
" km/h" +
'\n' +
"Other track speed limit = " +
16452 SpeedLimit23Str +
" km/h";
16457 LengthAndSpeedCaption =
"Top track length = " + Length01Str +
" m" +
'\n' +
"Bottom track length = " + Length23Str +
" m" +
'\n' +
16458 "Top track speed limit = " + SpeedLimit01Str +
" km/h" +
'\n' +
"Bottom track speed limit = " + SpeedLimit23Str +
" km/h";
16463 LengthAndSpeedCaption =
"Track length = " + Length01Str +
" m" +
'\n' +
"Track speed limit = " + SpeedLimit01Str +
" km/h";
16466 if(ActiveTrackFoundFlag)
16470 ShowTrackFloatFlag =
true;
16473 TrackFloat =
"Location = " + ATrackTN +
'\n' + LengthAndSpeedCaption +
'\n' +
"ID = " + AnsiString(ActiveTrackElement.
ElementID);
16475 else if(ATrackSN !=
"")
16477 TrackFloat =
"Location = " + ATrackSN +
'\n' + LengthAndSpeedCaption +
'\n' +
"ID = " + AnsiString(ActiveTrackElement.
ElementID);
16480 else if(InactiveTrackFoundFlag)
16482 TrackFloat =
"Location unnamed\n" + LengthAndSpeedCaption +
'\n' +
"ID = " + AnsiString(ActiveTrackElement.
ElementID);
16487 TrackFloat = LengthAndSpeedCaption +
'\n' +
"Track Element ID = " + AnsiString(ActiveTrackElement.
ElementID);
16493 SigAspectString =
"\nThree-aspect signal";
16497 SigAspectString =
"\nTwo-aspect signal";
16501 SigAspectString =
"\nGround signal";
16505 SigAspectString =
"\nFour-aspect signal";
16507 TrackFloat += SigAspectString;
16510 else if(InactiveTrackFoundFlag)
16513 ShowTrackFloatFlag =
true;
16516 if(IATrackSN ==
"")
16518 TrackFloat =
"Location unnamed\nID = " + AnsiString(InactiveTrackElement.
ElementID);
16522 TrackFloat =
"Location = " + IATrackSN +
'\n' +
"ID = " + AnsiString(InactiveTrackElement.
ElementID);
16527 TrackFloat =
"ID = " + AnsiString(InactiveTrackElement.
ElementID);
16533 bool OAListBoxFloatRequired =
false;
16538 AnsiString FormatOneDPStr =
"####0.0";
16539 AnsiString FormatNoDPStr =
"#######0";
16541 AnsiString MaxBrakeStr =
"";
16542 AnsiString SpecialStr =
"";
16547 int X =
OAListBox->ScreenToClient(MousePoint).x;
16548 int Y =
OAListBox->ScreenToClient(MousePoint).y;
16549 int TrainID = -1, ContinuationPos = -1;
16552 OAListBoxFloatRequired =
true;
16555 ShowTrainStatusFloatFlag =
true;
16559 ShowTrainTTFloatFlag =
true;
16561 if((TrainID > -1) && (ShowTrainStatusFloatFlag || ShowTrainTTFloatFlag))
16567 else if(ContinuationPos > -1)
16574 if(!OAListBoxFloatRequired)
16577 if(FoundFlag && !MouseOverOAPanel)
16585 ShowTrainStatusFloatFlag =
true;
16590 ShowTrainTTFloatFlag =
true;
16600 TrainStatusFloat =
"No trains expected";
16601 TrainTTFloat =
"No timetable";
16604 ShowTrainStatusFloatFlag =
true;
16608 ShowTrainTTFloatFlag =
true;
16619 AnsiString Caption;
16621 if(!ShowTrackFloatFlag && !ShowTrainStatusFloatFlag && !ShowTrainTTFloatFlag)
16627 else if(ShowTrackFloatFlag && !ShowTrainStatusFloatFlag && !ShowTrainTTFloatFlag)
16629 Caption = TrackFloat;
16631 else if(!ShowTrackFloatFlag && ShowTrainStatusFloatFlag && !ShowTrainTTFloatFlag)
16633 Caption = TrainStatusFloat;
16635 else if(ShowTrackFloatFlag && ShowTrainStatusFloatFlag && !ShowTrainTTFloatFlag)
16637 Caption = TrainStatusFloat +
'\n' +
'\n' + TrackFloat;
16639 else if(!ShowTrackFloatFlag && !ShowTrainStatusFloatFlag && ShowTrainTTFloatFlag)
16641 if(TrainStatusFloat ==
"No trains expected")
16643 Caption = TrainStatusFloat;
16647 Caption = TrainTTFloat;
16650 else if(ShowTrackFloatFlag && !ShowTrainStatusFloatFlag && ShowTrainTTFloatFlag)
16652 if(TrainStatusFloat ==
"No trains expected")
16654 Caption = TrainStatusFloat +
'\n' +
'\n' + TrackFloat;
16658 Caption = TrainTTFloat +
'\n' +
'\n' + TrackFloat;
16661 else if(!ShowTrackFloatFlag && ShowTrainStatusFloatFlag && ShowTrainTTFloatFlag)
16663 if(TrainStatusFloat ==
"No trains expected")
16665 Caption = TrainStatusFloat;
16669 Caption = TrainStatusFloat +
'\n' +
'\n' + TrainTTFloat;
16672 else if(ShowTrackFloatFlag && ShowTrainStatusFloatFlag && ShowTrainTTFloatFlag)
16674 if(TrainStatusFloat ==
"No trains expected")
16676 Caption = TrainStatusFloat +
'\n' +
'\n' + TrackFloat;
16680 Caption = TrainStatusFloat +
'\n' +
'\n' + TrainTTFloat +
'\n' +
'\n' + TrackFloat;
16683 int WindowOffsetLeft = 16;
16684 int WindowOffsetRight = 16;
16685 if(OAListBoxFloatRequired)
16687 WindowOffsetLeft = 32;
16688 WindowOffsetRight = 64;
16693 int Left = ScreenX +
MainScreen->Left + WindowOffsetRight;
16698 Left = ScreenX -
FloatingPanel->Width + 32 - WindowOffsetLeft;
16736 AnsiString &TrainTTFloat)
16745 (CTEIt->second.TrainDataEntryPtr->TrainOperatingDataVector.at(CTEIt->second.RepeatNumber).RunningEntry !=
NotStarted)))
16752 AnsiString ServiceReferenceInfo =
"";
16756 if(CTEIt->second.RepeatNumber == 0)
16760 ServiceReferenceInfo =
"\nFirst service of ref. " + TTDEPtr->
ServiceReference;
16764 ServiceReferenceInfo =
"\nFirst service";
16769 ServiceReferenceInfo =
"\nRepeat service no. " + AnsiString(CTEIt->second.RepeatNumber);
16773 ServiceReferenceInfo =
"\nRepeat service no. " + AnsiString(CTEIt->second.RepeatNumber) +
" of ref. " + TTDEPtr->
ServiceReference;
16780 ServiceReferenceInfo =
"\nService reference " + TTDEPtr->
ServiceReference;
16785 SpecialStr =
"\nTrain under signaller control";
16787 if(EntrySpeed > LineSpeedLimit)
16789 EntrySpeed = LineSpeedLimit;
16795 if(EntrySpeed > LineSpeedLimit)
16797 EntrySpeed = LineSpeedLimit;
16802 TDateTime TempTime = CTEIt->first;
16804 TrainStatusFloat = CTEIt->second.HeadCode +
": " + CTEIt->second.Description + ServiceReferenceInfo +
"\nEntry speed " +
16805 AnsiString::FormatFloat(FormatNoDPStr, EntrySpeed) +
"km/h" + SpecialStr +
"\nDelayed, was due at " +
Utilities->
Format96HHMM(TempTime);
16809 TDateTime TempTime = CTEIt->first;
16811 TrainStatusFloat = CTEIt->second.HeadCode +
": " + CTEIt->second.Description + ServiceReferenceInfo +
"\nEntry speed " +
16812 AnsiString::FormatFloat(FormatNoDPStr, EntrySpeed) +
"km/h" + SpecialStr +
"\nExpected at " +
Utilities->
Format96HHMM(TempTime);
16819 CTEIt->second.IncrementalDigits);
16833 AnsiString HeadCode =
"", ServiceReferenceInfo =
"", Status =
"", CurrSpeedStr =
"", BrakePCStr =
"", NextStopStr =
"", TimeLeftStr =
"",
16834 TimeToNextMovementStr =
"", MassStr =
"", PowerStr =
"";
16835 AnsiString FormatOneDPStr =
"####0.0", MaxBrakeStr =
"", MaxSpeedStr =
"", TrainStatusFloat;
16839 MassStr = AnsiString::FormatFloat(FormatNoDPStr, ((
double)Train.
Mass) / 1000);
16840 PowerStr = AnsiString::FormatFloat(FormatNoDPStr, Train.
PowerAtRail / 1000 / 0.8);
16843 MaxSpeedStr =
"30";
16847 MaxSpeedStr = AnsiString::FormatFloat(FormatNoDPStr, Train.
MaxRunningSpeed);
16852 TDateTime TimeLeft;
16854 MaxBrakeStr = AnsiString::FormatFloat(FormatNoDPStr, (Train.
MaxBrakeRate * Train.
Mass / 9810));
16866 ServiceReferenceInfo =
"\nFirst service";
16871 ServiceReferenceInfo =
"\nRepeat service no. " + AnsiString(Train.
RepeatNumber);
16889 Status =
"Stopped on signaller's instruction";
16893 Status =
"Not in service";
16897 Status =
"Stopped at buffers";
16901 Status =
"Stopped at signal";
16905 Status =
"Stopped - forward track occupied";
16919 Status =
"Stopped without power - train failed";
16923 Status =
"Stopped without power";
16928 Status =
"Stopped - signal passed at danger";
16932 Status =
"Derailed";
16936 Status =
"Crashed";
16944 Status =
"Accelerating";
16951 if(BrakePCRate < 55)
16953 Status =
"Light braking";
16955 else if(BrakePCRate < 90)
16957 Status =
"Heavy braking";
16961 Status =
"Emergency braking";
16968 if(BrakePCRate < 55)
16970 Status =
"Light braking";
16972 else if(BrakePCRate < 90)
16974 Status =
"Heavy braking";
16978 Status =
"Emergency braking";
16985 Status =
"Accelerating";
16991 Status =
"Accelerating";
16993 ((Train.
ExitSpeedFull - Train.
ExitSpeedHalf) * (
double(ElapsedDeltaT - FirstHalfTimeDeltaT) / double(SecondHalfTimeDeltaT)));
17002 Status =
"Coasting - train failed";
17006 Status =
"Coasting - no power";
17012 Status =
"Constant speed";
17023 Status =
"Coasting - train failed";
17027 Status =
"Coasting - no power";
17033 Status =
"Constant speed";
17041 NextStopStr =
"At signaller's discretion";
17045 NextStopStr =
"None";
17054 SpecialStr =
"Train under signaller control" + AnsiString(
'\n');
17058 SpecialStr =
"Restricted speed - being called on" + AnsiString(
'\n');
17061 if(RemTimeHalf < 0)
17066 if(RemTimeFull < 0)
17070 if(RemTimeHalf > 0)
17072 TimeLeft = RemTimeHalf;
17076 TimeLeft = RemTimeFull;
17078 TimeToNextMovementStr =
"Time to next movement (sec) = " + TimeLeftStr.FormatFloat(FormatOneDPStr, TimeLeft);
17081 TimeToNextMovementStr =
"";
17085 TrainStatusFloat = HeadCode +
": " + Train.
TrainDataEntryPtr->
Description + ServiceReferenceInfo +
'\n' +
"Maximum train speed " + MaxSpeedStr +
17086 "km/h; Power " + PowerStr +
"kW" +
'\n' +
"Mass " + MassStr +
"Te; Brakes " + MaxBrakeStr +
"Te" +
'\n' + SpecialStr + Status +
'\n' +
"Next: " +
17091 TrainStatusFloat = HeadCode +
": " + Train.
TrainDataEntryPtr->
Description + ServiceReferenceInfo +
'\n' +
"Maximum train speed " + MaxSpeedStr +
17092 "km/h; Power " + PowerStr +
"kW" +
'\n' +
"Mass " + MassStr +
"Te; Brakes " + MaxBrakeStr +
"Te" +
'\n' + SpecialStr + Status +
": " +
17093 CurrSpeedStr.FormatFloat(FormatNoDPStr, CurrSpeed) +
"km/h" +
'\n' +
"Next: " + NextStopStr;
17096 return(TrainStatusFloat);
17175 InfoPanel->Caption =
"PRE-START: Route setting in progress";
17179 InfoPanel->Caption =
"OPERATING: Route setting in progress";
17302 bool Manual =
false;
17351 throw Exception(
"Failed to find a route at LC position HLoc = " + (AnsiString)H +
" VLoc = " + (AnsiString)V);
17356 if(RouteNumber > -1)
17390 bool SaveRailwayButtonsFlag =
true;
17399 SaveRailwayButtonsFlag =
false;
17417 SaveRailwayButtonsFlag =
false;
17425 SaveRailwayButtonsFlag =
false;
17476 bool ZoomFlag =
true, HomeFlag =
true, NewHomeFlag =
true, ScreenLeftFlag =
true, ScreenRightFlag =
true, ScreenUpFlag =
true, ScreenDownFlag =
true,
17477 TrackBuildPanelEnabledFlag =
true, PrefDirPanelEnabledFlag =
true, OperatingPanelEnabledFlag =
true, TimetablePanelEnabledFlag =
true;
17479 AnsiString TrackBuildPanelLabelCaptionStr =
"Build/modify";
17480 AnsiString PrefDirPanelLabelCaptionStr =
"Preferred direction selection";
17481 AnsiString OperatingPanelLabelCaptionStr =
"Operation";
17482 AnsiString TimetablePanelLabelCaptionStr =
"Timetable editor";
17489 ScreenLeftFlag =
false;
17493 ScreenRightFlag =
false;
17497 ScreenUpFlag =
false;
17501 ScreenDownFlag =
false;
17509 ScreenLeftFlag =
false;
17513 ScreenRightFlag =
false;
17517 ScreenUpFlag =
false;
17521 ScreenDownFlag =
false;
17528 NewHomeFlag =
false;
17529 ScreenLeftFlag =
false;
17530 ScreenRightFlag =
false;
17531 ScreenUpFlag =
false;
17532 ScreenDownFlag =
false;
17537 TrackBuildPanelEnabledFlag =
false;
17538 TrackBuildPanelLabelCaptionStr =
"Disabled";
17539 PrefDirPanelEnabledFlag =
false;
17540 PrefDirPanelLabelCaptionStr =
"Disabled";
17541 OperatingPanelEnabledFlag =
false;
17542 OperatingPanelLabelCaptionStr =
"Disabled";
17543 TimetablePanelEnabledFlag =
false;
17544 TimetablePanelLabelCaptionStr =
"Disabled";
17552 OperatingPanelEnabledFlag =
false;
17553 OperatingPanelLabelCaptionStr =
"Disabled";
17556 NewHomeFlag =
false;
17557 ScreenLeftFlag =
false;
17558 ScreenRightFlag =
false;
17559 ScreenUpFlag =
false;
17560 ScreenDownFlag =
false;
17573 NewHomeFlag =
false;
17574 ScreenLeftFlag =
false;
17575 ScreenRightFlag =
false;
17576 ScreenUpFlag =
false;
17577 ScreenDownFlag =
false;
17583 NewHomeFlag =
false;
17584 ScreenLeftFlag =
false;
17585 ScreenRightFlag =
false;
17586 ScreenUpFlag =
false;
17587 ScreenDownFlag =
false;
17594 NewHomeFlag =
false;
17595 ScreenLeftFlag =
false;
17596 ScreenRightFlag =
false;
17597 ScreenUpFlag =
false;
17598 ScreenDownFlag =
false;
17637 if(ScreenRightFlag)
17661 if(OperatingPanelEnabledFlag)
17669 if(TrackBuildPanelEnabledFlag)
17677 if(PrefDirPanelEnabledFlag)
17685 if(TimetablePanelEnabledFlag)
17708 bool CallOnValid =
false;
17714 CallOnValid =
true;
17809 Screen->Cursor = TCursor(-2);
17853 Caption =
"Railway: New railway under development";
17857 Caption =
"Railway: " +
RailwayTitle +
" under development";
17952 TFont *TempFont =
new TFont;
17954 TempFont->Style.Clear();
17955 TempFont->Name =
"MS Sans Serif";
17956 TempFont->Size = 10;
17958 TempFont->Charset = (TFontCharset)(0);
18066 if(NonPrefDirChangesMade)
18092 AnsiString CurrentDateTimeStr =
"", TimetableTimeStr =
"", SessionFileStr =
"";
18093 Screen->Cursor = TCursor(-11);
18094 CurrentDateTimeStr = TDateTime::CurrentDateTime().FormatString(
"dd-mm-yyyy hh.nn.ss");
18097 TimetableTimeStr = TimetableTimeStr.SubString(1, 2) +
'.' + TimetableTimeStr.SubString(4, 2) +
'.' + TimetableTimeStr.SubString(7, 2);
18100 SessionFileStr =
LoadSessionDialog->InitialDir +
"\\Session " + CurrentDateTimeStr +
"; Timetable time " + TimetableTimeStr +
"; " +
RailwayTitle +
18102 std::ofstream SessionFile(SessionFileStr.c_str());
18103 if(!(SessionFile.fail()))
18145 SessionFile.close();
18146 DeleteFile(SessionFileStr);
18147 Screen->Cursor = TCursor(-2);
18195 SessionFile.close();
18206 Screen->Cursor = TCursor(-2);
18209 catch(
const Exception &e)
18242 Screen->Cursor = TCursor(-11);
18247 if(!(SessionFile.fail()))
18254 int LastCharBeforeFloat = TempString.LastDelimiter(
'*');
18255 if((LastCharBeforeFloat == 0) || (LastCharBeforeFloat == TempString.Length()))
18262 AnsiString FloatStr = TempString.SubString(LastCharBeforeFloat + 1, TempString.Length() - LastCharBeforeFloat);
18278 bool GraphicsFollow =
false;
18294 SessionFile.close();
18295 Screen->Cursor = TCursor(-2);
18296 ShowMessage(
"Corruption in preferred direction section of the session file, session can't be loaded");
18304 SessionFile.close();
18305 Screen->Cursor = TCursor(-2);
18306 ShowMessage(
"Corruption in route section of the session file, session can't be loaded");
18318 if(TempString ==
"***BarriersDownVector***")
18326 SessionFile.close();
18327 Screen->Cursor = TCursor(-2);
18328 ShowMessage(
"Unable to load timetable section of the session file, session can't be loaded");
18335 SessionFile.close();
18336 Screen->Cursor = TCursor(-2);
18337 throw Exception(
"TimetableTitle null in LoadSession");
18355 ShowMessage(
"Performance logfile failed to open, logs won't be saved. Ensure that there is a folder named " +
PERFLOG_DIR_NAME +
18356 " in the folder where the 'Railway.exe' program file resides");
18362 SessionFile.get(TempChar);
18363 while(!SessionFile.eof() && ((TempChar ==
'\n') || (TempChar ==
'\0')))
18365 SessionFile.get(TempChar);
18367 if(SessionFile.eof())
18371 SessionFile.close();
18383 double PowerDouble;
18393 SessionFile.get(TempChar);
18394 while(!SessionFile.eof() && ((TempChar ==
'\n') || (TempChar ==
'\0')))
18396 SessionFile.get(TempChar);
18398 if(!SessionFile.eof())
18400 if((TempChar !=
'0') && (TempChar !=
'1'))
18402 throw Exception(
"TempChar value = " + AnsiString(TempChar) +
", should be 0 or 1");
18405 if(TempChar ==
'0')
18412 SessionFile.get(TempChar);
18413 while(!SessionFile.eof() && ((TempChar ==
'\n') || (TempChar ==
'\0')))
18415 SessionFile.get(TempChar);
18417 if(!SessionFile.eof())
18420 AnsiString TempString = TempChar;
18421 SessionFile.get(TempChar);
18422 while((TempChar !=
'\n') && (TempChar !=
'\0'))
18424 TempString = TempString + TempChar;
18425 SessionFile.get(TempChar);
18434 SessionFile.close();
18471 ShowMessage(
"Session file integrity check failed, unable to load " +
LoadSessionDialog->FileName);
18473 Screen->Cursor = TCursor(-2);
18477 catch(
const Exception &e)
18479 if((e.Message.Pos(
"esource") > 0) || (e.Message.Pos(
"arameter") > 0))
18481 Screen->Cursor = TCursor(-2);
18492 UnicodeString MessageStr =
18493 "Insufficient memory available to load the file, and partial load likely to be corrupt. Application will terminate. Try loading the session as the first action after reloading the program.";
18495 Application->MessageBox(MessageStr.c_str(), L
"Out of memory", MB_OK | MB_ICONERROR);
18496 Application->Terminate();
18573 if(OpMode ==
"PreStart")
18636 AnsiString OpMode =
"";
18643 else if((OpMode !=
"PreStart") && (OpMode !=
"NotPreStart"))
18872 SessionFile.close();
18873 SessionFile.open(SessionFileStr.c_str(), std::ios_base::app | std::ios_base::binary);
18887 ShowMessage(
"Failed to open temporary timetable file. Unable to save the session");
18893 char *Buffer =
new char[10000];
18898 BytesRead = FileRead(Handle, Buffer, 10000);
18899 SessionFile.write(Buffer, BytesRead);
18900 if(BytesRead < 10000)
18908 SessionFile.close();
18909 SessionFile.open(SessionFileStr.c_str(), std::ios_base::app | std::ios_base::out);
18933 if(!FileExists(TimetableFileName))
18939 ErrorFile.open(ErrorFileStr.c_str(), std::ios_base::app | std::ios_base::binary);
18941 int Handle = FileOpen(TimetableFileName, fmOpenRead);
18948 Handle = FileOpen(TimetableFileName, fmOpenRead);
18958 char *Buffer =
new char[10000];
18963 BytesRead = FileRead(Handle, Buffer, 10000);
18964 ErrorFile.write(Buffer, BytesRead);
18965 if(BytesRead < 10000)
18974 ErrorFile.open(ErrorFileStr.c_str(), std::ios_base::app | std::ios_base::out);
19002 int TempTTFileNumber = 0;
19004 while(FileExists(
CurDir +
"\\TmpTT" + AnsiString(TempTTFileNumber) +
".tmp"))
19006 TempTTFileNumber++;
19014 if(!TTBFile.fail())
19016 char *Buffer =
new char[10000];
19017 char TempChar = (char)(SessionFile.peek());
19018 if(TempChar ==
'\n')
19020 SessionFile.get(TempChar);
19022 if(!SessionFile.getline(Buffer, 10000,
'\0'))
19031 for(
int x = 0; x < 10000; x++)
19033 if(Buffer[x] !=
'\0')
19042 while(AnsiString(Buffer) !=
"***End***")
19044 TTBFile.write(Buffer, Count);
19045 TTBFile.write(&Zero, 1);
19047 if(!SessionFile.getline(Buffer, 10000,
'\0'))
19056 for(
int x = 0; x < 10000; x++)
19058 if(Buffer[x] !=
'\0')
19072 bool GiveMessagesFalse =
false;
19073 bool CheckLocationsExistInRailwayTrue =
true;
19076 std::ifstream TTBLFile(
TempTTFileName.c_str(), std::ios_base::binary);
19077 if(TTBLFile.is_open())
19079 bool SessionFileTrue =
true;
19110 for(
int x = 0; x < NumberOfTrainEntries; x++)
19118 for(
int y = 0; y < NumberOfTrains; y++)
19143 AnsiString OutString;
19150 while(OutString !=
"***End***")
19159 if(SessionFile.fail())
19164 int NumberOfTrainEntries;
19171 for(
int x = 0; x < NumberOfTrainEntries; x++)
19173 int NumberOfTrains;
19179 for(
int y = 0; y < NumberOfTrains; y++)
19208 bool EndOfFile =
false;
19210 char *TrainTimetableString =
new char[10000];
19214 TTBLFile.getline(TrainTimetableString, 10000,
'\0');
19215 if(TTBLFile.eof() && (TrainTimetableString[0] ==
'\0'))
19222 AnsiString OneLine(TrainTimetableString);
19223 bool FinalCallTrue =
true;
19225 CheckLocationsExistInRailway))
19227 TTBLFile.getline(TrainTimetableString, 10000,
'\0');
19228 if(TTBLFile.eof() && (TrainTimetableString[0] ==
'\0'))
19231 throw Exception(
"Timetable FinalCall error - no start time on own line, Count = 0");
19233 OneLine = AnsiString(TrainTimetableString);
19239 TTBLFile.getline(TrainTimetableString, 10000,
'\0');
19240 if(TTBLFile.eof() && (TrainTimetableString[0] ==
'\0'))
19247 OneLine = AnsiString(TrainTimetableString);
19253 throw Exception(
"Timetable FinalCall error in processing one timetable line, Count = " + AnsiString(Count));
19255 if(EndOfFile && (Count < 2))
19258 throw Exception(
"Timetable FinalCall error - too few or no relevant entries, Count = " + AnsiString(Count));
19263 delete[] TrainTimetableString;
19264 bool TwoLocationFlag;
19272 ShowMessage(
"Timetable secondary integrity check failed - unable to load");
19309 bool EndOfFile =
false;
19311 char *TrainTimetableString =
new char[10000];
19315 TTBLFile.getline(TrainTimetableString, 10000,
'\0');
19316 if(TTBLFile.eof() && (TrainTimetableString[0] ==
'\0'))
19323 AnsiString OneLine(TrainTimetableString);
19324 bool FinalCallTrue =
true;
19326 CheckLocationsExistInRailway))
19328 TTBLFile.getline(TrainTimetableString, 10000,
'\0');
19329 if(TTBLFile.eof() && (TrainTimetableString[0] ==
'\0'))
19332 throw Exception(
"Timetable FinalCall error - no start time on own line, Count = 0");
19334 OneLine = AnsiString(TrainTimetableString);
19340 TTBLFile.getline(TrainTimetableString, 10000,
'\0');
19341 if(TTBLFile.eof() && (TrainTimetableString[0] ==
'\0'))
19348 OneLine = AnsiString(TrainTimetableString);
19354 throw Exception(
"Timetable FinalCall error in processing one timetable line, Count = " + AnsiString(Count));
19356 if(EndOfFile && (Count < 2))
19359 throw Exception(
"Timetable FinalCall error - too few or no relevant entries, Count = " + AnsiString(Count));
19364 delete[] TrainTimetableString;
19365 bool TwoLocationFlag;
19376 else if(TwoLocationFlag)
19378 AnsiString AllServices =
"", Suffix =
"";
19388 AllServices = AllServices + *TLLIt +
", ";
19394 Suffix =
"(more than 5, first 5 are) ";
19398 TwoLocationNameLabel->Caption =
"The following services have two or more locations with the same name without a change of\n"
19399 "direction between them. If this isn't intended then please correct them.\n\n"
19400 "Before ticking the check box please be sure that all services are correct.\n\n"
19401 "Services: " + Suffix +
" " + AllServices;
19405 TwoLocationNameLabel->Caption =
"The following service has two or more locations with the same name without a change of\n"
19406 "direction between them. If this isn't intended then please correct it.\n\n"
19407 "Service: " + AllServices;
19437 std::ifstream InFile(FileName.c_str());
19439 int NumberOfActiveElements;
19440 bool GraphicsFollow =
false;
19442 if(InFile.is_open())
19589 if((TempString !=
"***BarriersDownVector***") && (TempString !=
"***Timetable***"))
19595 if(TempString ==
"***BarriersDownVector***")
19639 InFile.open(FileName.c_str());
19640 if(InFile.is_open())
19661 bool GraphicsFollow =
false;
19782 if((TempString !=
"***BarriersDownVector***") && (TempString !=
"***Timetable***"))
19788 if(TempString ==
"***BarriersDownVector***")
19867 InFile.get(TempChar);
19868 while(!InFile.eof() && ((TempChar ==
'\n') || (TempChar ==
'\0')))
19870 InFile.get(TempChar);
19901 double PowerDouble;
19931 AnsiString TempString =
"", Line1 =
"", Line2 =
"", Line3 =
"", Line4 =
"", Line5 =
"";
19932 char *Buffer =
new char[1000];
19935 InFile.get(TempChar);
19936 InFile.getline(Buffer, 1000);
19937 TempString = AnsiString(Buffer);
19938 if(TempString ==
"***End of performance file***")
19945 while(TempString !=
"***End of performance file***")
19949 InFile.getline(Buffer, 1000);
19950 TempString = AnsiString(Buffer);
19962 AnsiString TempString =
"";
19965 InFile.get(TempChar);
19966 if(TempChar !=
'\n')
19976 while(TempString !=
"***End of performance file***")
19997 AnsiString OneLine = Text.SubString(1, Text.Pos(
'\x0D'));
19998 while((OneLine.Length() > 0) && OneLine[OneLine.Length()] <
' ')
20000 OneLine.SetLength(OneLine.Length() - 1);
20002 Text = Text.SubString(Text.Pos(
'\x0D'), Text.Length());
20003 while((Text.Length() > 0) && Text[1] <
' ')
20005 Text = Text.SubString(2, (Text.Length() - 1));
20007 OutFile << OneLine.c_str() <<
'\n';
20028 InfoPanel->Caption =
"PRE-START: Select AUTOMATIC SIGNAL ROUTE start signal, or left click points to change manually";
20032 InfoPanel->Caption =
"OPERATING: Select AUTOMATIC SIGNAL ROUTE start signal, or left click points to change manually";
20045 InfoPanel->Caption =
"PRE-START: Select PREFERRED ROUTE start signal, or left click points to change manually";
20049 InfoPanel->Caption =
"OPERATING: Select PREFERRED ROUTE start signal, or left click points to change manually";
20062 InfoPanel->Caption =
"PRE-START: Select PREFERRED ROUTE start signal, or left click points to change manually";
20066 InfoPanel->Caption =
"OPERATING: Select PREFERRED ROUTE start signal, or left click points to change manually";
20079 InfoPanel->Caption =
"PRE-START: Select UNRESTRICTED ROUTE start location, or left click points to change manually";
20083 InfoPanel->Caption =
"OPERATING: Select UNRESTRICTED ROUTE start location, or left click points to change manually";
20097 InfoPanel->Caption =
"PRE-START: Select UNRESTRICTED ROUTE start location, or left click points to change manually";
20101 InfoPanel->Caption =
"OPERATING: Select UNRESTRICTED ROUTE start location, or left click points to change manually";
20128 InfoPanel->Caption =
"Left click screen to zoom in at that position";
20133 InfoPanel->Caption =
"PAUSED: Railway state changes disabled";
20211 Screen->Cursor = TCursor(-11);
20212 AnsiString ErrorFileStr =
CurDir +
"\\errorlog.err";
20213 std::ofstream ErrorFile(ErrorFileStr.c_str());
20215 if(!(ErrorFile.fail()))
20218 int ScreenX = Mouse->CursorPos.x -
MainScreen->ClientOrigin.x;
20219 int ScreenY = Mouse->CursorPos.y -
MainScreen->ClientOrigin.y;
20220 AnsiString MouseStr =
"Posx: " + AnsiString(ScreenX) +
"; Posy: " + AnsiString(ScreenY);
20230 ErrorFile << Item.c_str() <<
'\n';
20237 ErrorFile << Item.c_str() <<
'\n';
20375 Screen->Cursor = TCursor(-2);
20392 int TempTTFileNumber = 0;
20394 while(FileExists(
CurDir +
"\\TmpTT" + AnsiString(TempTTFileNumber) +
".tmp"))
20396 TempTTFileNumber++;
20399 int InHandle = FileOpen(InFileName, fmOpenRead);
20402 while(InHandle < 0)
20404 InHandle = FileOpen(InFileName, fmOpenRead);
20409 ShowMessage(
"Failed to open timetable file, make sure it's spelled correctly, it exists and isn't open in another application");
20417 while(OutHandle < 0)
20424 ShowMessage(
"Failed to save temporary timetable file, sessions can't be saved - try again, may only be a temporary problem");
20425 FileClose(InHandle);
20430 int CountIn, CountOut;
20431 char *Buffer =
new char[10000];
20435 CountIn = FileRead(InHandle, Buffer, 10000);
20436 CountOut = FileWrite(OutHandle, Buffer, CountIn);
20437 if(CountOut != CountIn)
20439 ShowMessage(
"Error in writing to the temporary timetable file, sessions can't be saved - try again, may only be a temporary problem");
20441 FileClose(InHandle);
20442 FileClose(OutHandle);
20446 if(CountIn < 10000)
20452 FileClose(InHandle);
20453 FileClose(OutHandle);
20498 int VarElements = 0;
20499 bool NamedLocPresent =
false;
20507 throw Exception(
"Error - failed to find track element at " + AnsiString(TE.
HLoc) +
" & " + AnsiString(TE.
VLoc) +
" in SetLengths");
20516 NamedLocPresent =
true;
20521 if(SpeedLimit != -1)
20528 if(SpeedLimit != -1)
20539 if((NamedLocPresent) && (VarElements > 0) && ((Distance / VarElements) < 50))
20543 ShowMessage(
"Note: Named location elements are quite short. If they are too short the simulation might be too unrealistic.\n\nThis message will not be shown again.");
20547 if((NamedLocPresent) && (VarElements > 0) && ((Distance / VarElements) > 200))
20551 ShowMessage(
"Note: Named location elements are quite long. If they are too long the simulation might be too unrealistic.\n\nThis message will not be shown again.");
20561 if((VarElements * 20) > Distance)
20563 ShowMessage(
"Required distance is less than the minimum, will set each element to the minimum (20m)");
20564 Distance = (VarElements * 20);
20566 if(VarElements == 0)
20569 ShowMessage(
"No elements selected");
20574 int RemainingDistance = Distance, RemainingVarElements = VarElements, NextLength = RemainingDistance / VarElements;
20582 if(NextLength < 20)
20608 RemainingDistance -= NextLength;
20609 RemainingVarElements--;
20610 if(RemainingVarElements > 0)
20612 NextLength = RemainingDistance / RemainingVarElements;
20640 ShowMessage(
"Nothing to save!");
20646 SaveRailwayDialog->Filter =
"Development file (*.dev)|*.dev|Railway file (*.rly)|*.rly";
20659 Screen->Cursor = TCursor(-11);
20661 AnsiString Extension =
"";
20669 if(!(VecFile.fail()))
20697 if((LastChar ==
'y') || (LastChar ==
'Y'))
20726 ShowMessage(
"File open failed prior to save");
20731 ShowMessage(
"Can't save: extension must be either '.dev', or '.rly' with railway ready for operation");
20733 Screen->Cursor = TCursor(-2);
20770 System::WideChar ValidityBuffer[14];
20771 Clipboard()->GetTextBuf(ValidityBuffer, 14);
20773 Clipboard()->Close();
20831 catch(
const EClipboardException &e)
20890 bool TextFound =
false;
20915 AnsiString(VPos) +
"," + AnsiString((
short)UseEnteredPosition));
20916 int VPosHi, VPosLo, TextPosHi, TextPosLo;
20919 if(!UseEnteredPosition)
20926 int Depth = abs(Font->Height);
20927 TextPosHi = VPosHi + 20;
20928 TextPosLo = VPosLo - Depth - 4;
20931 if(TextPosLo >= ScreenPosLo)
20935 else if(TextPosHi < ScreenPosHi)
20941 VPos = ScreenPosLo + 288;
20993 catch(
const Exception &e)
21070 AnsiString OpTimeToActDisplay;
21071 AnsiString OpTimeToActString;
21072 AnsiString HeadCode;
21073 float OpTimeToActFloat;
21085 HeadCode = HCandTrainPosParam.first;
21086 if(OpTimeToActFloat < 0.25)
21088 OpTimeToActString =
"NOW";
21090 else if(OpTimeToActFloat < 1)
21092 OpTimeToActString =
"<1";
21096 OpTimeToActString = AnsiString(floor(OpTimeToActFloat));
21098 if(OpTimeToActFloat < 60)
21100 OpTimeToActDisplay = HeadCode + AnsiString(
'\t') + OpTimeToActString;
21101 OAListBox->Items->Add(OpTimeToActDisplay);
21125 TPicture *PicPtr =
new TPicture;
21127 UGME.second = PicPtr;
21138 catch(
const EInvalidGraphic &e)
21141 "Incorrect file format, the file can't be loaded.\nEnsure that the file you want is a valid graphic file with extension .bmp, .gif, .jpg, or .png");
21144 catch(
const Exception &e)
21159 std::wstringstream wss;
21162 wss <<
"RlyClpBrdCopy\n";
21166 wss <<
"RlyClpBrd_Cut\n";
21171 wss << TTVIt->SpeedTag;
21173 for(
int AnsLen = 0; AnsLen <= TTVIt->ActiveTrackElementName.Length(); AnsLen++)
21175 if((TTVIt->ActiveTrackElementName).c_str()[AnsLen] !=
'\0')
21177 wss << (TTVIt->ActiveTrackElementName).c_str()[AnsLen];
21184 for(
int AnsLen = 0; AnsLen <= TTVIt->ElementID.Length(); AnsLen++)
21186 if((TTVIt->ElementID).c_str()[AnsLen] !=
'\0')
21188 wss << (TTVIt->ElementID).c_str()[AnsLen];
21195 for(
int AnsLen = 0; AnsLen <= TTVIt->LocationName.Length(); AnsLen++)
21197 if((TTVIt->LocationName).c_str()[AnsLen] !=
'\0')
21199 wss << (TTVIt->LocationName).c_str()[AnsLen];
21206 wss << TTVIt->CallingOnSet;
21208 wss << TTVIt->LCPlotted;
21210 wss << TTVIt->TempTrackMarker01;
21212 wss << TTVIt->TempTrackMarker23;
21214 wss << TTVIt->Attribute;
21216 wss << TTVIt->Conn[0];
21218 wss << TTVIt->Conn[1];
21220 wss << TTVIt->Conn[2];
21222 wss << TTVIt->Conn[3];
21224 wss << TTVIt->ConnLinkPos[0];
21226 wss << TTVIt->ConnLinkPos[1];
21228 wss << TTVIt->ConnLinkPos[2];
21230 wss << TTVIt->ConnLinkPos[3];
21232 wss << TTVIt->HLoc;
21234 wss << TTVIt->VLoc;
21236 wss << TTVIt->Length01;
21238 wss << TTVIt->Length23;
21240 wss << TTVIt->SpeedLimit01;
21242 wss << TTVIt->SpeedLimit23;
21244 wss << TTVIt->StationEntryStopLinkPos1;
21246 wss << TTVIt->StationEntryStopLinkPos2;
21248 wss << TTVIt->TrainIDOnElement;
21250 wss << TTVIt->TrainIDOnBridgeTrackPos01;
21252 wss << TTVIt->TrainIDOnBridgeTrackPos23;
21254 wss << int(TTVIt->SigAspect);
21257 wss <<
"$$$" <<
'\n';
21263 for(
int AnsLen = 0; AnsLen <= TTVIt->TextString.Length(); AnsLen++)
21265 if((TTVIt->TextString).c_str()[AnsLen] !=
'\0')
21267 wss << (TTVIt->TextString).c_str()[AnsLen];
21274 wss << TTVIt->HPos;
21276 wss << TTVIt->VPos;
21278 for(
int AnsLen = 0; AnsLen <= AnsiString(TTVIt->Font->Name).Length(); AnsLen++)
21280 if(AnsiString(TTVIt->Font->Name).c_str()[AnsLen] !=
'\0')
21282 wss << AnsiString(TTVIt->Font->Name).c_str()[AnsLen];
21289 wss << TTVIt->Font->Size;
21291 if((TTVIt->Font->Color < 0) || (TTVIt->Font->Color > 0xFFFFFF))
21297 wss << int(TTVIt->Font->Color) <<
'\n';
21299 wss << int(TTVIt->Font->Charset) <<
'\n';
21302 wss <<
"$$$" <<
'\n';
21313 wss <<
"$$$" <<
'\n';
21322 wss << PDVIt->GetTrackVectorPosition();
21324 wss << PDVIt->GetHLoc();
21326 wss << PDVIt->GetVLoc();
21328 wss << PDVIt->GetELink();
21330 wss << PDVIt->GetELinkPos();
21332 wss << PDVIt->GetXLink();
21334 wss << PDVIt->GetXLinkPos();
21336 wss << PDVIt->GetEXNumber();
21340 wss <<
"$$$" <<
'\n';
21343 Clipboard()->Clear();
21344 Clipboard()->SetTextBuf(&(wss.str()[0]));
21345 Clipboard()->Close();
21350 catch(
const EClipboardException &e)
21357 catch(
const Exception &e)
21372 ValidResult =
false;
21373 System::WideChar *SelectVectorBuffer =
new System::WideChar[4000000];
21374 int StreamSize = 0;
21375 StreamSize = Clipboard()->GetTextBuf(SelectVectorBuffer, 4000000);
21376 Clipboard()->Clear();
21377 Clipboard()->Close();
21378 if(StreamSize < 14)
21383 std::wstringstream wss;
21384 wss << SelectVectorBuffer;
21385 ClpBrdValid = AnsiString(SelectVectorBuffer).SubString(1, 13);
21387 delete[] SelectVectorBuffer;
21394 int MarkerCounter = 0;
21396 wchar_t LineString[1000];
21401 wss.getline(LineString, 100);
21404 THVPair SelectTrackMapKeyPair;
21408 wss.getline(LineString, 100);
21409 if(AnsiString(LineString) ==
"$$$")
21416 wss.getline(LineString, 100);
21418 wss.getline(LineString, 100);
21420 wss.getline(LineString, 100);
21423 wss.getline(LineString, 100);
21425 wss.getline(LineString, 100);
21426 TE.
LCPlotted = AnsiString(LineString).ToInt();
21427 wss.getline(LineString, 100);
21429 wss.getline(LineString, 100);
21432 wss.getline(LineString, 100);
21433 TE.
Attribute = AnsiString(LineString).ToInt();
21434 wss.getline(LineString, 100);
21435 TE.
Conn[0] = AnsiString(LineString).ToInt();
21436 wss.getline(LineString, 100);
21437 TE.
Conn[1] = AnsiString(LineString).ToInt();
21438 wss.getline(LineString, 100);
21439 TE.
Conn[2] = AnsiString(LineString).ToInt();
21440 wss.getline(LineString, 100);
21441 TE.
Conn[3] = AnsiString(LineString).ToInt();
21442 wss.getline(LineString, 100);
21443 TE.
ConnLinkPos[0] = AnsiString(LineString).ToInt();
21444 wss.getline(LineString, 100);
21445 TE.
ConnLinkPos[1] = AnsiString(LineString).ToInt();
21446 wss.getline(LineString, 100);
21447 TE.
ConnLinkPos[2] = AnsiString(LineString).ToInt();
21448 wss.getline(LineString, 100);
21449 TE.
ConnLinkPos[3] = AnsiString(LineString).ToInt();
21450 wss.getline(LineString, 100);
21451 TE.
HLoc = AnsiString(LineString).ToInt();
21452 wss.getline(LineString, 100);
21453 TE.
VLoc = AnsiString(LineString).ToInt();
21454 wss.getline(LineString, 100);
21455 TE.
Length01 = AnsiString(LineString).ToInt();
21456 wss.getline(LineString, 100);
21457 TE.
Length23 = AnsiString(LineString).ToInt();
21458 wss.getline(LineString, 100);
21460 wss.getline(LineString, 100);
21462 wss.getline(LineString, 100);
21464 wss.getline(LineString, 100);
21466 wss.getline(LineString, 100);
21468 wss.getline(LineString, 100);
21470 wss.getline(LineString, 100);
21473 wss.getline(LineString, 100);
21474 int temp = AnsiString(LineString).ToInt();
21495 SelectTrackMapKeyPair.first = TE.
HLoc;
21496 SelectTrackMapKeyPair.second = TE.
VLoc;
21497 SelectTrackMapEntry.first = SelectTrackMapKeyPair;
21499 SelectTrackMap.insert(SelectTrackMapEntry);
21504 AnsiString FontName;
21505 int FontSize, FontColour, FontCharset, FontStyle;
21508 wss.getline(LineString, 1000);
21509 if(AnsiString(LineString) ==
"$$$")
21517 wss.getline(LineString, 1000);
21518 TI.
HPos = AnsiString(LineString).ToInt();
21519 wss.getline(LineString, 1000);
21520 TI.
VPos = AnsiString(LineString).ToInt();
21521 wss.getline(LineString, 1000);
21522 FontName = AnsiString(LineString).c_str();
21523 wss.getline(LineString, 1000);
21524 FontSize = AnsiString(LineString).ToInt();
21525 wss.getline(LineString, 1000);
21526 FontColour = AnsiString(LineString).ToInt();
21527 wss.getline(LineString, 1000);
21528 FontCharset = AnsiString(LineString).ToInt();
21529 wss.getline(LineString, 1000);
21530 FontStyle = AnsiString(LineString).ToInt();
21532 TFont *NewFont =
new TFont;
21533 NewFont->Name = FontName;
21534 NewFont->Size = FontSize;
21535 NewFont->Color =
static_cast<TColor
>(FontColour);
21536 NewFont->Charset = FontCharset;
21543 wss.getline(LineString, 100);
21544 SelectBitmap->Height = AnsiString(LineString).ToInt();
21545 wss.getline(LineString, 100);
21547 wss.getline(LineString, 100);
21548 SelectRect.left = AnsiString(LineString).ToInt();
21549 wss.getline(LineString, 100);
21550 SelectRect.top = AnsiString(LineString).ToInt();
21551 wss.getline(LineString, 100);
21552 if(AnsiString(LineString) ==
"$$$")
21559 int TempTVPos, TempHLoc, TempVLoc, TempELink, TempELinkPos, TempXLink, TempXLinkPos, TempEXNumber, ATVecPos;
21564 wss.getline(LineString, 100);
21565 if(AnsiString(LineString) ==
"$$$")
21571 TempTVPos = AnsiString(LineString).ToInt();
21572 wss.getline(LineString, 100);
21573 TempHLoc = AnsiString(LineString).ToInt();
21574 wss.getline(LineString, 100);
21575 TempVLoc = AnsiString(LineString).ToInt();
21576 wss.getline(LineString, 100);
21577 TempELink = AnsiString(LineString).ToInt();
21578 wss.getline(LineString, 100);
21579 TempELinkPos = AnsiString(LineString).ToInt();
21580 wss.getline(LineString, 100);
21581 TempXLink = AnsiString(LineString).ToInt();
21582 wss.getline(LineString, 100);
21583 TempXLinkPos = AnsiString(LineString).ToInt();
21584 wss.getline(LineString, 100);
21585 TempEXNumber = AnsiString(LineString).ToInt();
21594 TempPrefDirElement.
SetELink(TempELink);
21596 TempPrefDirElement.
SetXLink(TempXLink);
21603 if(MarkerCounter == 4)
21605 ValidResult =
true;
21610 catch(
const EClipboardException &e)
21612 ValidResult =
false;
21616 catch(
const Exception &e)
21618 ValidResult =
false;